From 13bf8241cecbbce2e782ebf2ad741944e3fb5115 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Apr 2022 05:40:37 +0000 Subject: [PATCH 001/143] Auto-generated commit 5b1a28c2ece0f7a9c9dce97a11a3655d5bf08500 --- CONTRIBUTORS | 28 + LICENSE | 481 +++++++++ NOTICE | 1 + README.md | 245 +++++ index.d.ts | 70 ++ index.mjs | 4 + index.mjs.map | 1 + package.json | 43 + stats.html | 2689 +++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 3562 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..8a7672d --- /dev/null +++ b/README.md @@ -0,0 +1,245 @@ + + +# Min and Max View Buffer Indices + +[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] + +> Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. + + + +
+ +
+ + + + + + + +
+ +## Usage + +```javascript +import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs'; +``` + +#### minmaxViewBufferIndex( shape, strides, offset ) + +Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. + +```javascript +// Array shape: +var shape = [ 2, 2 ]; + +// Stride array: +var strides = [ 2, 1 ]; + +// Index offset which specifies the location of the first indexed value: +var offset = 0; + +var idx = minmaxViewBufferIndex( shape, strides, offset ); +// returns [ 0, 3 ] +``` + +#### minmaxViewBufferIndex.assign( shape, strides, offset, out ) + +Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. + +```javascript +var shape = [ 2, 2 ]; +var strides = [ -1, -2 ]; +var offset = 3; + +var out = [ 0, 0 ]; +var idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); +// returns [ 0, 3 ] + +var bool = ( idx === out ); +// returns true +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## 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..d0c86f3 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,70 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2021 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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'; + +/** +* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. +* +* @param shape - array shape +* @param strides - stride array +* @param offset - index offset +* @returns linear indices +* +* @example +* var shape = [ 10, 10 ]; +* var strides = [ 10, 1 ]; +* var offset = 10; +* +* var idx = minmaxViewBufferIndex( shape, strides, offset ); +* // returns [ 10, 109 ] +* +* @example +* var shape = [ 10, 10 ]; +* var strides = [ -10, -1 ]; +* var offset = 99; +* +* var idx = minmaxViewBufferIndex( shape, strides, offset ); +* // returns [ 0, 99 ] +* +* @example +* var shape = [ 10, 10 ]; +* var strides = [ 1, 10 ]; +* var offset = 10; +* +* var idx = minmaxViewBufferIndex( shape, strides, offset ); +* // returns [ 10, 109 ] +* +* @example +* var shape = [ 10, 10 ]; +* var strides = [ -1, -10 ]; +* var offset = 99; +* +* var idx = minmaxViewBufferIndex( shape, strides, offset ); +* // returns [ 0, 99 ] +*/ +declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; // tslint-disable-line max-line-length + + +// EXPORTS // + +export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..9f6ac0a --- /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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";var e=function(r,e,n){var t,i,o,s,a;for(t=r.length,i=n,o=n,a=0;a0?o+=s*(r[a]-1):s<0&&(i+=s*(r[a]-1))}return[i,o]},n=function(r,e,n,t){var i,o,s,a,f;for(i=r.length,o=n,s=n,f=0;f0?s+=a*(r[f]-1):a<0&&(o+=a*(r[f]-1))}return t[0]=o,t[1]=s,t};r(e,"assign",n);var t=e;export{n as assign,t as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..6333b31 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/assign.js","../lib/index.js","../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n"],"names":["main","shape","strides","offset","ndims","min","max","s","i","length","assign","out","require$$0","lib"],"mappings":";;iHA8GA,ICzCAA,ECPA,SAAgCC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,IAGxB,MAAO,CAAEH,EAAKC,IDbfI,EDSA,SAAgCT,EAAOC,EAASC,EAAQQ,GACvD,IAAIP,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAG,EAAK,GAAMR,EACXQ,EAAK,GAAMR,EACJQ,GAERJ,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,IAKxB,OAFAG,EAAK,GAAMN,EACXM,EAAK,GAAML,EACJK,GCpCRC,EAOAZ,EAAA,SAAAU,GAKA,IAAAG,EAAAb"} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..2db6552 --- /dev/null +++ b/package.json @@ -0,0 +1,43 @@ +{ + "name": "@stdlib/ndarray-base-minmax-view-buffer-index", + "version": "0.0.0", + "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", + "license": "Apache-2.0", + "type": "module", + "main": "./index.mjs", + "homepage": "https://stdlib.io", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "keywords": [ + "stdlib", + "stdtypes", + "types", + "base", + "ndarray", + "strides", + "minimum", + "min", + "maximum", + "max", + "minmax", + "linear", + "index", + "idx", + "view", + "multidimensional", + "array", + "utilities", + "utility", + "utils", + "util" + ], + "funding": { + "type": "patreon", + "url": "https://www.patreon.com/athan" + } +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..e729694 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + From e0207515b6c13b6e6a5c28d001e0842443557c3d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 30 Jun 2022 23:46:20 +0000 Subject: [PATCH 002/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 55ba9ad..336b42a 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.0.x", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-library-manifest": "^0.0.x" + "@stdlib/utils-library-manifest": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-is-array": "^0.0.x", @@ -100,4 +101,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From c104ae17154263337837d55dad56c7e408341e81 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 14:21:57 +0000 Subject: [PATCH 003/143] Remove files --- index.d.ts | 70 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2764 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 d0c86f3..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9f6ac0a..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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";var e=function(r,e,n){var t,i,o,s,a;for(t=r.length,i=n,o=n,a=0;a0?o+=s*(r[a]-1):s<0&&(i+=s*(r[a]-1))}return[i,o]},n=function(r,e,n,t){var i,o,s,a,f;for(i=r.length,o=n,s=n,f=0;f0?s+=a*(r[f]-1):a<0&&(o+=a*(r[f]-1))}return t[0]=o,t[1]=s,t};r(e,"assign",n);var t=e;export{n as assign,t as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 6333b31..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/assign.js","../lib/index.js","../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n"],"names":["main","shape","strides","offset","ndims","min","max","s","i","length","assign","out","require$$0","lib"],"mappings":";;iHA8GA,ICzCAA,ECPA,SAAgCC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,IAGxB,MAAO,CAAEH,EAAKC,IDbfI,EDSA,SAAgCT,EAAOC,EAASC,EAAQQ,GACvD,IAAIP,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAG,EAAK,GAAMR,EACXQ,EAAK,GAAMR,EACJQ,GAERJ,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,IAKxB,OAFAG,EAAK,GAAMN,EACXM,EAAK,GAAML,EACJK,GCpCRC,EAOAZ,EAAA,SAAAU,GAKA,IAAAG,EAAAb"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index e729694..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From cdbec61c6b2cb719dd6e4a178477681366f252a5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 14:22:51 +0000 Subject: [PATCH 004/143] 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 | 146 +- benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 2689 +++++++++++++++++ test/test.js | 336 -- 45 files changed, 2721 insertions(+), 4697 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 ac4a34c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-06-30T21:26:56.218Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 94545a8..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/minmax-view-buffer-index) 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 31578b4..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/minmax-view-buffer-index) 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 + + ```
@@ -161,106 +160,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main() { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -287,7 +187,7 @@ int main() { ## 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]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b9b9e11..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index 753a2ff..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 `minmax_view_buffer_index`. -*/ -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -void print_version() { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -double tic() { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random double on the interval [0,1]. -* -* @return random double -*/ -double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -double benchmark() { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index f07975b..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/minmax-view-buffer-index" -click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b4f3d7e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The function does not compile if provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The function does not compile if provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The function does not compile if provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The function does not compile if provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index c94f7ee..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main() { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index aa1cbcd..d0c86f3 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..9bd59d6 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a6e4176 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport main from './main.js' ;\nimport assign from './assign.js' ;\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;iHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,IAGxB,MAAO,CAAEH,EAAKC,GCJf,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,IAKxB,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,EC7BRC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index 336b42a..f5966b2 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.0.8", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-library-manifest": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.0.x", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.0.x", - "@stdlib/ndarray-base-shape2strides": "^0.0.x", - "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..08081e4 --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From 160f326e69d8c401a3d9271e7a427ff336c0599f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 17:20:31 +0000 Subject: [PATCH 005/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 55ba9ad..336b42a 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.0.x", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-library-manifest": "^0.0.x" + "@stdlib/utils-library-manifest": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-is-array": "^0.0.x", @@ -100,4 +101,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From ddf15075471982d0a3e4f3bc2608a8d181df1f11 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 02:00:50 +0000 Subject: [PATCH 006/143] Remove files --- index.d.ts | 70 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2764 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 d0c86f3..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9bd59d6..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a6e4176..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport main from './main.js' ;\nimport assign from './assign.js' ;\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;iHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,IAGxB,MAAO,CAAEH,EAAKC,GCJf,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,IAKxB,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,EC7BRC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 08081e4..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 0f908651d58151b4d7ece0c9e151d3a88a912658 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 02:01:40 +0000 Subject: [PATCH 007/143] 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 | 146 +- benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 2689 +++++++++++++++++ test/test.js | 336 -- 45 files changed, 2721 insertions(+), 4697 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 47921dc..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-07-01T00:46:48.270Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 94545a8..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/minmax-view-buffer-index) 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 31578b4..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/minmax-view-buffer-index) 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 + + ```
@@ -161,106 +160,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main() { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -287,7 +187,7 @@ int main() { ## 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]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b9b9e11..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index 753a2ff..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 `minmax_view_buffer_index`. -*/ -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -void print_version() { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -double tic() { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random double on the interval [0,1]. -* -* @return random double -*/ -double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -double benchmark() { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index f07975b..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/minmax-view-buffer-index" -click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b4f3d7e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The function does not compile if provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The function does not compile if provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The function does not compile if provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The function does not compile if provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index c94f7ee..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main() { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index aa1cbcd..d0c86f3 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..9bd59d6 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a6e4176 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport main from './main.js' ;\nimport assign from './assign.js' ;\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;iHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,IAGxB,MAAO,CAAEH,EAAKC,GCJf,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,IAKxB,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,EC7BRC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index 336b42a..f5966b2 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.0.8", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-library-manifest": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.0.x", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.0.x", - "@stdlib/ndarray-base-shape2strides": "^0.0.x", - "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b8acb50 --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From 9d3078767b3dd817024b4de748c7d188e6784c5d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 18:34:55 +0000 Subject: [PATCH 008/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 55ba9ad..336b42a 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.0.x", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-library-manifest": "^0.0.x" + "@stdlib/utils-library-manifest": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-is-array": "^0.0.x", @@ -100,4 +101,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From a6ad6c8b3535df7e63257b72cb0c4411654bc06e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 18:47:23 +0000 Subject: [PATCH 009/143] Remove files --- index.d.ts | 70 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2764 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 d0c86f3..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9bd59d6..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a6e4176..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport main from './main.js' ;\nimport assign from './assign.js' ;\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;iHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,IAGxB,MAAO,CAAEH,EAAKC,GCJf,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,IAKxB,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,EC7BRC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b8acb50..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 7ba9c70c3bc392038c14a6d5d945ac6c06feaaae Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 18:48:11 +0000 Subject: [PATCH 010/143] 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 | 146 +- benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 2689 +++++++++++++++++ test/test.js | 336 -- 44 files changed, 2721 insertions(+), 4662 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 94545a8..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/minmax-view-buffer-index) 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 31578b4..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/minmax-view-buffer-index) 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 + + ```
@@ -161,106 +160,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main() { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -287,7 +187,7 @@ int main() { ## 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]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b9b9e11..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index 753a2ff..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 `minmax_view_buffer_index`. -*/ -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -void print_version() { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -double tic() { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random double on the interval [0,1]. -* -* @return random double -*/ -double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -double benchmark() { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index f07975b..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/minmax-view-buffer-index" -click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b4f3d7e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The function does not compile if provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The function does not compile if provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The function does not compile if provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The function does not compile if provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index c94f7ee..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main() { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index aa1cbcd..d0c86f3 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..9bd59d6 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a6e4176 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport main from './main.js' ;\nimport assign from './assign.js' ;\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;iHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,IAGxB,MAAO,CAAEH,EAAKC,GCJf,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,IAKxB,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,EC7BRC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index 336b42a..f5966b2 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.0.8", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-library-manifest": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.0.x", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.0.x", - "@stdlib/ndarray-base-shape2strides": "^0.0.x", - "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..9800c61 --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From 143630fdfb48bc884fa7cd187149a89ada2fe3d4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 03:37:17 +0000 Subject: [PATCH 011/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 55ba9ad..336b42a 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.0.x", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-library-manifest": "^0.0.x" + "@stdlib/utils-library-manifest": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-is-array": "^0.0.x", @@ -100,4 +101,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 5d38eb173ee6c64bb9c5d34ed319cb78ca3e9111 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 13:54:26 +0000 Subject: [PATCH 012/143] Remove files --- index.d.ts | 70 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2764 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 d0c86f3..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9bd59d6..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a6e4176..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport main from './main.js' ;\nimport assign from './assign.js' ;\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;iHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,IAGxB,MAAO,CAAEH,EAAKC,GCJf,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,IAKxB,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,EC7BRC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 9800c61..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From ed6df124ada464bb6f62d391d5daa89bf8c44503 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 13:55:19 +0000 Subject: [PATCH 013/143] 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 | 146 +- benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 2689 +++++++++++++++++ test/test.js | 336 -- 45 files changed, 2721 insertions(+), 4736 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 f6ac0ce..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-08-01T00:50:05.105Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 94545a8..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/minmax-view-buffer-index) 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 31578b4..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/minmax-view-buffer-index) 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 + + ```
@@ -161,106 +160,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main() { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -287,7 +187,7 @@ int main() { ## 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]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b9b9e11..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index 753a2ff..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 `minmax_view_buffer_index`. -*/ -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -void print_version() { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -double tic() { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random double on the interval [0,1]. -* -* @return random double -*/ -double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -double benchmark() { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index f07975b..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/minmax-view-buffer-index" -click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b4f3d7e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The function does not compile if provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The function does not compile if provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The function does not compile if provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The function does not compile if provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index c94f7ee..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main() { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index aa1cbcd..d0c86f3 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..9bd59d6 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a6e4176 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport main from './main.js' ;\nimport assign from './assign.js' ;\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;iHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,IAGxB,MAAO,CAAEH,EAAKC,GCJf,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,IAKxB,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,EC7BRC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index 336b42a..f5966b2 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.0.8", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-library-manifest": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.0.x", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.0.x", - "@stdlib/ndarray-base-shape2strides": "^0.0.x", - "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b3c33df --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From 174fd9d83e0bfaf236bb145b9ba09b4a9f01ed31 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 03:19:44 +0000 Subject: [PATCH 014/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 55ba9ad..336b42a 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.0.x", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-library-manifest": "^0.0.x" + "@stdlib/utils-library-manifest": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-is-array": "^0.0.x", @@ -100,4 +101,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From ec9c1cc03c7c9aca333b00376d8326322dbf2fef Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 16:16:56 +0000 Subject: [PATCH 015/143] Remove files --- index.d.ts | 70 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2764 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 d0c86f3..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9bd59d6..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a6e4176..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport main from './main.js' ;\nimport assign from './assign.js' ;\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;iHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,IAGxB,MAAO,CAAEH,EAAKC,GCJf,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,IAKxB,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,EC7BRC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b3c33df..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From c0cdd5d847a53ae0b1a954437af04252a255bb20 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 16:18:07 +0000 Subject: [PATCH 016/143] 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 | 146 +- benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 2689 +++++++++++++++++ test/test.js | 336 -- 45 files changed, 2721 insertions(+), 4752 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 fdd789d..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-09-01T00:45:56.502Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 94545a8..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/minmax-view-buffer-index) 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 31578b4..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/minmax-view-buffer-index) 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 + + ```
@@ -161,106 +160,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main() { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -287,7 +187,7 @@ int main() { ## 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]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b9b9e11..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index 753a2ff..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 `minmax_view_buffer_index`. -*/ -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -void print_version() { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -double tic() { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random double on the interval [0,1]. -* -* @return random double -*/ -double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -double benchmark() { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index f07975b..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/minmax-view-buffer-index" -click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b4f3d7e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The function does not compile if provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The function does not compile if provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The function does not compile if provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The function does not compile if provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index c94f7ee..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main() { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index aa1cbcd..d0c86f3 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..9bd59d6 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a6e4176 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport main from './main.js' ;\nimport assign from './assign.js' ;\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;iHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,IAGxB,MAAO,CAAEH,EAAKC,GCJf,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,IAKxB,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,EC7BRC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index 336b42a..f5966b2 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.0.8", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-library-manifest": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.0.x", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.0.x", - "@stdlib/ndarray-base-shape2strides": "^0.0.x", - "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..af640d1 --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From 75047670cd3d75ec8cd1875c35184198e0c96cd2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 03:38:44 +0000 Subject: [PATCH 017/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 55ba9ad..336b42a 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.0.x", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-library-manifest": "^0.0.x" + "@stdlib/utils-library-manifest": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-is-array": "^0.0.x", @@ -100,4 +101,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From e63ca5e18bda1d5e4e38d2031444ee099bc48f5f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 13:11:45 +0000 Subject: [PATCH 018/143] Remove files --- index.d.ts | 70 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2764 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 d0c86f3..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9bd59d6..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a6e4176..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport main from './main.js' ;\nimport assign from './assign.js' ;\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;iHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,IAGxB,MAAO,CAAEH,EAAKC,GCJf,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,IAKxB,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,EC7BRC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index af640d1..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 68f6f28c7ba1930091ae5402ce84b7a997c279fd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 13:12:36 +0000 Subject: [PATCH 019/143] 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 | 146 +- benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 2689 +++++++++++++++++ test/test.js | 336 -- 45 files changed, 2721 insertions(+), 4752 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 5e81fff..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-10-01T01:10:22.471Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 94545a8..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/minmax-view-buffer-index) 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 31578b4..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/minmax-view-buffer-index) 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 + + ```
@@ -161,106 +160,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main() { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -287,7 +187,7 @@ int main() { ## 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]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b9b9e11..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index 753a2ff..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 `minmax_view_buffer_index`. -*/ -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -void print_version() { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -double tic() { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random double on the interval [0,1]. -* -* @return random double -*/ -double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -double benchmark() { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index f07975b..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/minmax-view-buffer-index" -click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index c94f7ee..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main() { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index aa1cbcd..d0c86f3 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..9bd59d6 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a6e4176 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport main from './main.js' ;\nimport assign from './assign.js' ;\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;iHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,IAGxB,MAAO,CAAEH,EAAKC,GCJf,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,IAKxB,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,EC7BRC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index 336b42a..f5966b2 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.0.8", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-library-manifest": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.0.x", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.0.x", - "@stdlib/ndarray-base-shape2strides": "^0.0.x", - "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..683afb3 --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From 6f21e4d0a626928a424651bf92ccdc15f69c3761 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 03:24:09 +0000 Subject: [PATCH 020/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 55ba9ad..336b42a 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.0.x", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-library-manifest": "^0.0.x" + "@stdlib/utils-library-manifest": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-is-array": "^0.0.x", @@ -100,4 +101,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From c3087817d0035a70d373eb861ab23357526b0fd9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 10:56:00 +0000 Subject: [PATCH 021/143] Remove files --- index.d.ts | 70 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2764 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 d0c86f3..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9bd59d6..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a6e4176..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport main from './main.js' ;\nimport assign from './assign.js' ;\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;iHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,IAGxB,MAAO,CAAEH,EAAKC,GCJf,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,IAKxB,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,EC7BRC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 683afb3..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 3e38640a2fbf6303f5d1c7f1eb8f53e916851142 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 10:57:00 +0000 Subject: [PATCH 022/143] 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 | 146 +- benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 4044 +++++++++++++++++ test/test.js | 336 -- 45 files changed, 4076 insertions(+), 4752 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 141a478..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-01T00:56:48.862Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 94545a8..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/minmax-view-buffer-index) 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 31578b4..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/minmax-view-buffer-index) 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 52f0548..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: '40 4 * * 4' - - # 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 + + ```
@@ -161,106 +160,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main() { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -287,7 +187,7 @@ int main() { ## 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]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b9b9e11..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index 753a2ff..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 `minmax_view_buffer_index`. -*/ -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -void print_version() { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -double tic() { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random double on the interval [0,1]. -* -* @return random double -*/ -double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -double benchmark() { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index f07975b..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/minmax-view-buffer-index" -click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index c94f7ee..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main() { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index aa1cbcd..d0c86f3 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..9bd59d6 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..9dcafde --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport main from './main.js' ;\nimport assign from './assign.js' ;\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;iHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index 336b42a..f5966b2 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.0.8", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-library-manifest": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.0.x", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.0.x", - "@stdlib/ndarray-base-shape2strides": "^0.0.x", - "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b63331e --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From 2002fe6b89edc2bcc5a8094c6a09619cccf31924 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 3 Nov 2022 23:38:55 +0000 Subject: [PATCH 023/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 55ba9ad..336b42a 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.0.x", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-library-manifest": "^0.0.x" + "@stdlib/utils-library-manifest": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-is-array": "^0.0.x", @@ -100,4 +101,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 017b864248d057439588e95e63ddbed44a607233 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 06:47:06 +0000 Subject: [PATCH 024/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4119 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 d0c86f3..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9bd59d6..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 9dcafde..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport main from './main.js' ;\nimport assign from './assign.js' ;\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;iHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b63331e..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 52736185b1d91a78f18c2473d6d25f2665d41863 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 06:48:10 +0000 Subject: [PATCH 025/143] 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 | 146 +- benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 4044 +++++++++++++++++ test/test.js | 336 -- 45 files changed, 4076 insertions(+), 4773 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 51dbb23..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-03T21:08:30.128Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 94545a8..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/minmax-view-buffer-index) 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 31578b4..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/minmax-view-buffer-index) 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 52f0548..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: '40 4 * * 4' - - # 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 + + ```
@@ -161,106 +160,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main() { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -287,7 +187,7 @@ int main() { ## 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]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b9b9e11..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index 753a2ff..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 `minmax_view_buffer_index`. -*/ -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -void print_version() { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -double tic() { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random double on the interval [0,1]. -* -* @return random double -*/ -double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -double benchmark() { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index f07975b..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/minmax-view-buffer-index" -click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index c94f7ee..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main() { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index aa1cbcd..d0c86f3 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..9bd59d6 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..9dcafde --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport main from './main.js' ;\nimport assign from './assign.js' ;\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;iHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index 336b42a..f5966b2 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.0.8", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-library-manifest": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.0.x", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.0.x", - "@stdlib/ndarray-base-shape2strides": "^0.0.x", - "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b7b974e --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From d2f9f2081a91caa9eba1f3dcee201f8c91caeb63 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 03:22:57 +0000 Subject: [PATCH 026/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b7b4c8b..7bdb7c9 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.0.x", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-library-manifest": "^0.0.x" + "@stdlib/utils-library-manifest": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-is-array": "^0.0.x", @@ -100,4 +101,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 8ca37c503c42ee174c641856397e2df6afa32cb6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 20:04:19 +0000 Subject: [PATCH 027/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4119 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 d0c86f3..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9bd59d6..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 9dcafde..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport main from './main.js' ;\nimport assign from './assign.js' ;\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;iHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b7b974e..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 59871a16d4cb4d5dbff01a0cda5352118a0582f4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 20:05:35 +0000 Subject: [PATCH 028/143] 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 | 146 +- benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 4044 +++++++++++++++++ test/test.js | 336 -- 45 files changed, 4076 insertions(+), 4778 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 a5906ad..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-12-01T00:58:51.497Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 94545a8..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/minmax-view-buffer-index) 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 31578b4..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/minmax-view-buffer-index) 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 52f0548..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: '40 4 * * 4' - - # 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 + + ```
@@ -161,106 +160,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main() { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -287,7 +187,7 @@ int main() { ## 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]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b9b9e11..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index 753a2ff..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 `minmax_view_buffer_index`. -*/ -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -void print_version() { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -double tic() { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random double on the interval [0,1]. -* -* @return random double -*/ -double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -double benchmark() { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index f07975b..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/minmax-view-buffer-index" -click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index c94f7ee..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main() { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index aa1cbcd..d0c86f3 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..9bd59d6 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..9a0797d --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;iHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index 7bdb7c9..f5966b2 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.0.8", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-library-manifest": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.0.x", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.0.x", - "@stdlib/ndarray-base-shape2strides": "^0.0.x", - "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..857f653 --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From 3ceddd3c9d939ab85804ccc5165a9de903c04633 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 03:13:16 +0000 Subject: [PATCH 029/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bd8e6bd..360446b 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.0.x", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-library-manifest": "^0.0.x" + "@stdlib/utils-library-manifest": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-is-array": "^0.0.x", @@ -100,4 +101,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 8be592d0f8992458eff0ca2c1314071c80a335d4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 08:00:24 +0000 Subject: [PATCH 030/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4119 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 d0c86f3..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9bd59d6..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 9a0797d..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;iHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 857f653..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 923cda2ad76fea4592873c50f10d165a616921a5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 08:01:13 +0000 Subject: [PATCH 031/143] 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 | 146 +- benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 4044 +++++++++++++++++ test/test.js | 336 -- 45 files changed, 4076 insertions(+), 4789 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 3f12869..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-01-01T00:46:02.176Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 94545a8..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/minmax-view-buffer-index) 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 31578b4..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/minmax-view-buffer-index) 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 52f0548..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: '40 4 * * 4' - - # 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 + + ```
@@ -161,106 +160,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main() { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -287,7 +187,7 @@ int main() { ## 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]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b9b9e11..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index 753a2ff..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 `minmax_view_buffer_index`. -*/ -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -void print_version() { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -double tic() { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random double on the interval [0,1]. -* -* @return random double -*/ -double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -double benchmark() { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index f07975b..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/minmax-view-buffer-index" -click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index c94f7ee..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main() { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index aa1cbcd..d0c86f3 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..81540f4 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..9a0797d --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;iHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index 360446b..f5966b2 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.0.8", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-library-manifest": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.0.x", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.0.x", - "@stdlib/ndarray-base-shape2strides": "^0.0.x", - "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..d8859e9 --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From a7b417ce41abe8581ea61458fd4de17cc86965ab Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 03:28:37 +0000 Subject: [PATCH 032/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bd8e6bd..360446b 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.0.x", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-library-manifest": "^0.0.x" + "@stdlib/utils-library-manifest": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-is-array": "^0.0.x", @@ -100,4 +101,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 062f999e3179768651d596a31f12c0ef16d13aac Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 14:14:49 +0000 Subject: [PATCH 033/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4119 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 d0c86f3..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 81540f4..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 9a0797d..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;iHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d8859e9..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 439df2aa83e0a00c4c7d173ffaa0b13ea0c040b6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 14:15:51 +0000 Subject: [PATCH 034/143] 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 | 146 +- benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 6177 +++++++++++++++++ test/test.js | 336 - 45 files changed, 6209 insertions(+), 4789 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 136e7f3..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-02-01T00:55:23.162Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 94545a8..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/minmax-view-buffer-index) 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 31578b4..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/minmax-view-buffer-index) 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 52f0548..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: '40 4 * * 4' - - # 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 + + ```
@@ -161,106 +160,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main() { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -287,7 +187,7 @@ int main() { ## 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]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b9b9e11..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index 753a2ff..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 `minmax_view_buffer_index`. -*/ -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -void print_version() { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -double tic() { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random double on the interval [0,1]. -* -* @return random double -*/ -double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -double benchmark() { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index f07975b..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/minmax-view-buffer-index" -click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index c94f7ee..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main() { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index aa1cbcd..d0c86f3 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..81540f4 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..9a0797d --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;iHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index 360446b..f5966b2 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.0.8", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-library-manifest": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.0.x", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.0.x", - "@stdlib/ndarray-base-shape2strides": "^0.0.x", - "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..0e055fc --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From d50ea2a73daf94e70b6ff454d848d8e4c5bb5a6b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 02:21:39 +0000 Subject: [PATCH 035/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index fdbb297..af69b16 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.0.14", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/utils-library-manifest": "^0.0.8" + "@stdlib/utils-library-manifest": "^0.0.8", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/assert-is-array": "^0.0.7", @@ -100,4 +101,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From ce1ed27d193951ff97b2d5e403929ad288a0257c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 05:42:37 +0000 Subject: [PATCH 036/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6252 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 d0c86f3..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 81540f4..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 9a0797d..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;iHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 0e055fc..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a76002908cd2cf7f6576d4af06caba8170501cc3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 05:43:37 +0000 Subject: [PATCH 037/143] 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 | 146 +- benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 6177 +++++++++++++++++ test/test.js | 336 - 45 files changed, 6209 insertions(+), 4924 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 b09e0ad..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-03-01T01:34:23.440Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 94545a8..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/minmax-view-buffer-index) 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 31578b4..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/minmax-view-buffer-index) 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 52f0548..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: '40 4 * * 4' - - # 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 + + ```
@@ -161,106 +160,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main() { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -287,7 +187,7 @@ int main() { ## 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]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b9b9e11..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index 753a2ff..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 `minmax_view_buffer_index`. -*/ -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -void print_version() { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -double tic() { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random double on the interval [0,1]. -* -* @return random double -*/ -double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -double benchmark() { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index 38d96d2..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/minmax-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index c94f7ee..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main() { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index aa1cbcd..d0c86f3 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..81540f4 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..9a0797d --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;iHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index af69b16..49035ac 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.0.8", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.14", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/utils-library-manifest": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.0.7", - "@stdlib/assert-is-nonnegative-integer-array": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.0.8", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.0.8", - "@stdlib/ndarray-base-shape2strides": "^0.0.8", - "@stdlib/ndarray-base-strides2offset": "^0.0.8", - "@stdlib/random-base-discrete-uniform": "^0.0.6", - "@stdlib/random-base-randu": "^0.0.8", - "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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..097671f --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From e0e9ee1c520c5b72b4958698e02bf35a0d94ae21 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 02:24:20 +0000 Subject: [PATCH 038/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index fdbb297..af69b16 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.0.14", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/utils-library-manifest": "^0.0.8" + "@stdlib/utils-library-manifest": "^0.0.8", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/assert-is-array": "^0.0.7", @@ -100,4 +101,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 8fee7d542eb1fc40296cf9af1092e8198f84fa2b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 05:31:22 +0000 Subject: [PATCH 039/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6252 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 d0c86f3..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 81540f4..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 9a0797d..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;iHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 097671f..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From bd48305f82e66eacc36a5e58d01f9c6d69dba6db Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 05:32:15 +0000 Subject: [PATCH 040/143] 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 | 146 +- benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 6177 +++++++++++++++++ test/test.js | 336 - 45 files changed, 6209 insertions(+), 4930 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 7a7ab70..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-04-01T01:40:37.820Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 94545a8..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/minmax-view-buffer-index) 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 31578b4..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/minmax-view-buffer-index) 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 52f0548..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: '40 4 * * 4' - - # 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 + + ```
@@ -161,106 +160,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main() { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -287,7 +187,7 @@ int main() { ## 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]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b9b9e11..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index 753a2ff..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 `minmax_view_buffer_index`. -*/ -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -void print_version() { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -double tic() { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random double on the interval [0,1]. -* -* @return random double -*/ -double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -double benchmark() { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index 38d96d2..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/minmax-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index c94f7ee..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main() { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index aa1cbcd..d0c86f3 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..81540f4 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..9a0797d --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;iHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index af69b16..49035ac 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.0.8", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.14", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/utils-library-manifest": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.0.7", - "@stdlib/assert-is-nonnegative-integer-array": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.0.8", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.0.8", - "@stdlib/ndarray-base-shape2strides": "^0.0.8", - "@stdlib/ndarray-base-strides2offset": "^0.0.8", - "@stdlib/random-base-discrete-uniform": "^0.0.6", - "@stdlib/random-base-randu": "^0.0.8", - "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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b99b871 --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From f91bf4cab2a7280e315d539a708470d1953151b9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 02:19:10 +0000 Subject: [PATCH 041/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index fdbb297..af69b16 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.0.14", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/utils-library-manifest": "^0.0.8" + "@stdlib/utils-library-manifest": "^0.0.8", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/assert-is-array": "^0.0.7", @@ -100,4 +101,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 9cb6f70d61ec16e42d87e5c5c5b2f88b43cefacf Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 05:19:05 +0000 Subject: [PATCH 042/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6252 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 d0c86f3..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 81540f4..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 9a0797d..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;iHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b99b871..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ac5ffb9503443874188fbf34e492eb05db5579a1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 05:19:50 +0000 Subject: [PATCH 043/143] 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 | 146 +- benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 6177 +++++++++++++++++ test/test.js | 336 - 45 files changed, 6209 insertions(+), 4930 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 85ff274..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-05-01T01:37:11.821Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 94545a8..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/minmax-view-buffer-index) 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 31578b4..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/minmax-view-buffer-index) 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 52f0548..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: '40 4 * * 4' - - # 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 + + ```
@@ -161,106 +160,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -287,7 +187,7 @@ int main( void ) { ## 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]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b9b9e11..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index 753a2ff..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 `minmax_view_buffer_index`. -*/ -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -void print_version() { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -double tic() { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random double on the interval [0,1]. -* -* @return random double -*/ -double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -double benchmark() { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index 38d96d2..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/minmax-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index 32b9185..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index aa1cbcd..d0c86f3 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..81540f4 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..9a0797d --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;iHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index af69b16..49035ac 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.0.8", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.14", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/utils-library-manifest": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.0.7", - "@stdlib/assert-is-nonnegative-integer-array": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.0.8", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.0.8", - "@stdlib/ndarray-base-shape2strides": "^0.0.8", - "@stdlib/ndarray-base-strides2offset": "^0.0.8", - "@stdlib/random-base-discrete-uniform": "^0.0.6", - "@stdlib/random-base-randu": "^0.0.8", - "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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..a091b7b --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From 7c9701ac61d3af871bc2797588d316ef70988bea Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 02:20:34 +0000 Subject: [PATCH 044/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index fdbb297..af69b16 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.0.14", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/utils-library-manifest": "^0.0.8" + "@stdlib/utils-library-manifest": "^0.0.8", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/assert-is-array": "^0.0.7", @@ -100,4 +101,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 6bd2c30082da1fa935b2f71c0cc1c916bcfd1633 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 05:32:38 +0000 Subject: [PATCH 045/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6252 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 d0c86f3..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 81540f4..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 9a0797d..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;iHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a091b7b..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c3717dce7b244c2a9161a26c849951e85562fb59 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 05:33:36 +0000 Subject: [PATCH 046/143] 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 | 146 +- benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 6177 +++++++++++++++++ test/test.js | 336 - 45 files changed, 6209 insertions(+), 4930 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 8a45134..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-06-01T01:37:23.577Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 94545a8..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/minmax-view-buffer-index) 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 31578b4..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/minmax-view-buffer-index) 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 52f0548..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: '40 4 * * 4' - - # 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 + + ```
@@ -161,106 +160,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -287,7 +187,7 @@ int main( void ) { ## 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]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b9b9e11..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index 753a2ff..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 `minmax_view_buffer_index`. -*/ -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -void print_version() { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -double tic() { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random double on the interval [0,1]. -* -* @return random double -*/ -double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -double benchmark() { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index 38d96d2..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/minmax-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index 32b9185..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index aa1cbcd..d0c86f3 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..81540f4 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..9a0797d --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;iHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index af69b16..49035ac 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.0.8", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.14", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/utils-library-manifest": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.0.7", - "@stdlib/assert-is-nonnegative-integer-array": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.0.8", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.0.8", - "@stdlib/ndarray-base-shape2strides": "^0.0.8", - "@stdlib/ndarray-base-strides2offset": "^0.0.8", - "@stdlib/random-base-discrete-uniform": "^0.0.6", - "@stdlib/random-base-randu": "^0.0.8", - "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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..15ed00f --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From fba0fbb51e0ab48e9ecc9bd312ec7f53d5b77dbe Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 02:20:28 +0000 Subject: [PATCH 047/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index fdbb297..af69b16 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.0.14", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/utils-library-manifest": "^0.0.8" + "@stdlib/utils-library-manifest": "^0.0.8", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/assert-is-array": "^0.0.7", @@ -100,4 +101,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From c9a1a3c1c07889ab954f1ece92af7ab3d342438b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 05:39:04 +0000 Subject: [PATCH 048/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6252 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 d0c86f3..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 81540f4..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 9a0797d..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;iHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 15ed00f..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c8bd0232b0f4006335f2f7e6a51c86dbdad40bed Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 05:39:57 +0000 Subject: [PATCH 049/143] 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 | 146 +- benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 6177 +++++++++++++++++ test/test.js | 336 - 45 files changed, 6209 insertions(+), 4930 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 4a56a02..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-07-01T01:37:35.993Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 94545a8..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/minmax-view-buffer-index) 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 31578b4..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/minmax-view-buffer-index) 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 52f0548..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: '40 4 * * 4' - - # 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 + + ```
@@ -161,106 +160,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -287,7 +187,7 @@ int main( void ) { ## 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]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b9b9e11..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index 753a2ff..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 `minmax_view_buffer_index`. -*/ -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -void print_version() { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -double tic() { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random double on the interval [0,1]. -* -* @return random double -*/ -double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -double benchmark() { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index 38d96d2..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/minmax-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index 32b9185..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index aa1cbcd..d0c86f3 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..81540f4 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..9a0797d --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;iHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index af69b16..49035ac 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.0.8", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.14", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/utils-library-manifest": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.0.7", - "@stdlib/assert-is-nonnegative-integer-array": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.0.8", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.0.8", - "@stdlib/ndarray-base-shape2strides": "^0.0.8", - "@stdlib/ndarray-base-strides2offset": "^0.0.8", - "@stdlib/random-base-discrete-uniform": "^0.0.6", - "@stdlib/random-base-randu": "^0.0.8", - "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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7374343 --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From 7807d39a863f8ad29be2461c41ecf4000c5b77e1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 02:29:00 +0000 Subject: [PATCH 050/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index fdbb297..af69b16 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.0.14", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/utils-library-manifest": "^0.0.8" + "@stdlib/utils-library-manifest": "^0.0.8", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/assert-is-array": "^0.0.7", @@ -100,4 +101,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 78dc76a27e91e861feefd84707bce53717c62f88 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 05:49:06 +0000 Subject: [PATCH 051/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6252 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 d0c86f3..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 81540f4..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 9a0797d..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;iHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7374343..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 8552380a5e53196987251aad4973b5f646a6befb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 05:49:56 +0000 Subject: [PATCH 052/143] 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 | 146 +- benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 6177 +++++++++++++++++ test/test.js | 336 - 45 files changed, 6209 insertions(+), 4930 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 b7d1888..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-08-01T01:40:27.133Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 94545a8..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/minmax-view-buffer-index) 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 31578b4..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/minmax-view-buffer-index) 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 52f0548..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: '40 4 * * 4' - - # 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 334eb59..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@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 + + ```
@@ -161,106 +160,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -287,7 +187,7 @@ int main( void ) { ## 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]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b9b9e11..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index 753a2ff..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 `minmax_view_buffer_index`. -*/ -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -void print_version() { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -double tic() { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random double on the interval [0,1]. -* -* @return random double -*/ -double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -double benchmark() { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index 38d96d2..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/minmax-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index 32b9185..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index aa1cbcd..d0c86f3 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..81540f4 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..9a0797d --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;iHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index af69b16..49035ac 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.0.8", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.14", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/utils-library-manifest": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.0.7", - "@stdlib/assert-is-nonnegative-integer-array": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.0.8", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.0.8", - "@stdlib/ndarray-base-shape2strides": "^0.0.8", - "@stdlib/ndarray-base-strides2offset": "^0.0.8", - "@stdlib/random-base-discrete-uniform": "^0.0.6", - "@stdlib/random-base-randu": "^0.0.8", - "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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..00497db --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From 743a518b4ea982648391c8249be048cc86d76c02 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 22 Sep 2023 23:15:11 +0000 Subject: [PATCH 053/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 54ac730..346e91c 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.1.0", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.0", - "@stdlib/utils-library-manifest": "^0.1.0" + "@stdlib/utils-library-manifest": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.0" }, "devDependencies": { "@stdlib/assert-is-array": "^0.1.0", @@ -100,4 +101,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From f3b0182f6ca84905bf8459706d2e448e4f651ff3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 22 Sep 2023 23:38:33 +0000 Subject: [PATCH 054/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6252 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 d0c86f3..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 81540f4..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 9a0797d..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;iHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 00497db..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ab83ff53bc2945f27483475aeb07edfddcd70764 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 22 Sep 2023 23:39:40 +0000 Subject: [PATCH 055/143] 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 | 146 +- benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 6177 +++++++++++++++++ test/test.js | 336 - 48 files changed, 6209 insertions(+), 4966 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c 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/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 94545a8..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/minmax-view-buffer-index) 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 31578b4..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/minmax-view-buffer-index) 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 52f0548..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: '40 4 * * 4' - - # 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 + + ```
@@ -172,106 +171,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -298,7 +198,7 @@ int main( void ) { ## 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]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b9b9e11..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index 753a2ff..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 `minmax_view_buffer_index`. -*/ -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -void print_version() { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -double tic() { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random double on the interval [0,1]. -* -* @return random double -*/ -double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -double benchmark() { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index 38d96d2..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/minmax-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/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 31431c6..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import minmaxViewBufferIndex from '../docs/types/index'; -export = minmaxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index f4a239a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var s=function(i,v){return function(){return v||i((v={exports:{}}).exports,v),v.exports}};var c=s(function(V,t){ -function q(i,v,n){var e,x,m,a,r;for(e=i.length,x=n,m=n,r=0;r0?m+=a*(i[r]-1):a<0&&(x+=a*(i[r]-1))}return[x,m]}t.exports=q -});var l=s(function(y,d){ -function f(i,v,n,e){var x,m,a,r,u;for(x=i.length,m=n,a=n,u=0;u0?a+=r*(i[u]-1):r<0&&(m+=r*(i[u]-1))}return e[0]=m,e[1]=a,e}d.exports=f -});var w=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),g=c(),B=l();w(g,"assign",B);module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index d90186a..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAuBC,EAAOC,EAASC,EAAS,CACxD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAM,OACdI,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKP,EAAOO,CAAE,IAAM,EACnB,MAAO,CAAEL,EAAQA,CAAO,EAEzBI,EAAIL,EAASM,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMN,EAAMO,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,CAAC,EAAE,GAExB,CACA,MAAO,CAAEH,EAAKC,CAAI,CACnB,CAKAP,EAAO,QAAUC,ICzFjB,IAAAS,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA+EA,SAASC,EAAuBC,EAAOC,EAASC,EAAQC,EAAM,CAC7D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQJ,EAAM,OACdK,EAAMH,EACNI,EAAMJ,EACAM,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKR,EAAOQ,CAAE,IAAM,EACnB,OAAAL,EAAK,CAAE,EAAID,EACXC,EAAK,CAAE,EAAID,EACJC,EAERI,EAAIN,EAASO,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMP,EAAMQ,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMP,EAAMQ,CAAC,EAAE,GAExB,CACA,OAAAL,EAAK,CAAE,EAAIE,EACXF,EAAK,CAAE,EAAIG,EACJH,CACR,CAKAL,EAAO,QAAUC,IC1CjB,IAAIU,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "ndims", "min", "max", "s", "i", "require_assign", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "out", "ndims", "min", "max", "s", "i", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index 32b9185..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 06beab9..67b8519 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..81540f4 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..9a0797d --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;iHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index 346e91c..c65e7a9 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.1.0", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.1.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.0", - "@stdlib/utils-library-manifest": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.1.0", - "@stdlib/assert-is-nonnegative-integer-array": "^0.0.8", - "@stdlib/bench": "^0.1.0", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.0.8", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.0.8", - "@stdlib/ndarray-base-shape2strides": "^0.1.0", - "@stdlib/ndarray-base-strides2offset": "^0.1.0", - "@stdlib/random-base-discrete-uniform": "^0.0.6", - "@stdlib/random-base-randu": "^0.0.8", - "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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..79efe15 --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From 2fd19f680a772fd11629d7a0b39c8c7ae41e006d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 22 Sep 2023 23:58:01 +0000 Subject: [PATCH 056/143] Update README.md for ESM bundle v0.1.0 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4a495b9..dfb8fd1 100644 --- a/README.md +++ b/README.md @@ -52,13 +52,13 @@ limitations under the License. ## Usage ```javascript -import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs'; +import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.1.0-esm/index.mjs'; ``` You can also import the following named exports from the package: ```javascript -import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs'; +import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.1.0-esm/index.mjs'; ``` #### minmaxViewBufferIndex( shape, strides, offset ) @@ -126,7 +126,7 @@ import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-d import shape2strides from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs'; import strides2offset from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs'; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-randu@esm/index.mjs'; -import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs'; +import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.1.0-esm/index.mjs'; var strides; var offset; From 73d4e303b93d0c7052430a29f8be777449d49833 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 22 Sep 2023 23:58:02 +0000 Subject: [PATCH 057/143] Auto-generated commit --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dfb8fd1..f61489c 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tags). For example, + ```javascript import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.1.0-esm/index.mjs'; ``` @@ -58,7 +63,7 @@ import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray You can also import the following named exports from the package: ```javascript -import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.1.0-esm/index.mjs'; +import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs'; ``` #### minmaxViewBufferIndex( shape, strides, offset ) @@ -126,7 +131,7 @@ import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-d import shape2strides from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs'; import strides2offset from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs'; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-randu@esm/index.mjs'; -import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.1.0-esm/index.mjs'; +import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs'; var strides; var offset; From 3cec75f9f1443b29d61280d9c1f24bcfb03b64b7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Oct 2023 02:49:26 +0000 Subject: [PATCH 058/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c4b4f58..cc7cddf 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.1.0", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.0", - "@stdlib/utils-library-manifest": "^0.1.0" + "@stdlib/utils-library-manifest": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.0" }, "devDependencies": { "@stdlib/assert-is-array": "^0.1.0", @@ -100,4 +101,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From cb724f12637f20696b8f2f618c2d3150e294fb2c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Oct 2023 20:39:02 +0000 Subject: [PATCH 059/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6252 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 67b8519..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 81540f4..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 9a0797d..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;iHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 79efe15..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a63c68da733e2c2ff8757083baf483336473be3f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Oct 2023 20:42:19 +0000 Subject: [PATCH 060/143] 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 | 146 +- benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 6177 +++++++++++++++++ test/dist/test.js | 336 - test/test.js | 336 - 50 files changed, 6209 insertions(+), 5361 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c 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/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 a808b17..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-10-01T01:21:50.029Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 94545a8..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/minmax-view-buffer-index) 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 ed2728d..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/minmax-view-buffer-index) 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 e0d7511..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: '40 4 * * 4' - - # 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 + + ```
@@ -172,106 +171,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -298,7 +198,7 @@ int main( void ) { ## 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]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b9b9e11..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index 753a2ff..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 `minmax_view_buffer_index`. -*/ -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -void print_version() { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -double tic() { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random double on the interval [0,1]. -* -* @return random double -*/ -double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -double benchmark() { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index 38d96d2..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/minmax-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/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 31431c6..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import minmaxViewBufferIndex from '../docs/types/index'; -export = minmaxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index f4a239a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var s=function(i,v){return function(){return v||i((v={exports:{}}).exports,v),v.exports}};var c=s(function(V,t){ -function q(i,v,n){var e,x,m,a,r;for(e=i.length,x=n,m=n,r=0;r0?m+=a*(i[r]-1):a<0&&(x+=a*(i[r]-1))}return[x,m]}t.exports=q -});var l=s(function(y,d){ -function f(i,v,n,e){var x,m,a,r,u;for(x=i.length,m=n,a=n,u=0;u0?a+=r*(i[u]-1):r<0&&(m+=r*(i[u]-1))}return e[0]=m,e[1]=a,e}d.exports=f -});var w=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),g=c(),B=l();w(g,"assign",B);module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index d90186a..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAuBC,EAAOC,EAASC,EAAS,CACxD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAM,OACdI,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKP,EAAOO,CAAE,IAAM,EACnB,MAAO,CAAEL,EAAQA,CAAO,EAEzBI,EAAIL,EAASM,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMN,EAAMO,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,CAAC,EAAE,GAExB,CACA,MAAO,CAAEH,EAAKC,CAAI,CACnB,CAKAP,EAAO,QAAUC,ICzFjB,IAAAS,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA+EA,SAASC,EAAuBC,EAAOC,EAASC,EAAQC,EAAM,CAC7D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQJ,EAAM,OACdK,EAAMH,EACNI,EAAMJ,EACAM,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKR,EAAOQ,CAAE,IAAM,EACnB,OAAAL,EAAK,CAAE,EAAID,EACXC,EAAK,CAAE,EAAID,EACJC,EAERI,EAAIN,EAASO,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMP,EAAMQ,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMP,EAAMQ,CAAC,EAAE,GAExB,CACA,OAAAL,EAAK,CAAE,EAAIE,EACXF,EAAK,CAAE,EAAIG,EACJH,CACR,CAKAL,EAAO,QAAUC,IC1CjB,IAAIU,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "ndims", "min", "max", "s", "i", "require_assign", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "out", "ndims", "min", "max", "s", "i", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index 32b9185..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 06beab9..67b8519 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..af1ec5b --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7cde065 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index cc7cddf..c65e7a9 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.1.0", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.1.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.0", - "@stdlib/utils-library-manifest": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.1.0", - "@stdlib/assert-is-nonnegative-integer-array": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.1.0", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.1.0", - "@stdlib/ndarray-base-shape2strides": "^0.1.0", - "@stdlib/ndarray-base-strides2offset": "^0.1.0", - "@stdlib/random-base-discrete-uniform": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..5d08e00 --- /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 b75e064..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From 62d905d404ec1088a07690c0a22363c4856299e7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 4 Oct 2023 02:31:09 +0000 Subject: [PATCH 061/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8ea7381..83b31eb 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.1.0", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/utils-library-manifest": "^0.1.1" + "@stdlib/utils-library-manifest": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/assert-is-array": "^0.1.0", @@ -100,4 +101,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 36e01cbe343088bd493dd89fcdcf9e5f08633d7c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 4 Oct 2023 11:56:42 +0000 Subject: [PATCH 062/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6252 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 67b8519..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index af1ec5b..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7cde065..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5d08e00..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ccfb67b4fb239b10ae9d5ccb3a2d6d4b57c333ba Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 4 Oct 2023 12:00:13 +0000 Subject: [PATCH 063/143] 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 | 146 +- benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 6177 +++++++++++++++++ test/dist/test.js | 336 - test/test.js | 336 - 49 files changed, 6209 insertions(+), 5360 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c 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/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 94545a8..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/minmax-view-buffer-index) 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 ed2728d..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/minmax-view-buffer-index) 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 e0d7511..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: '40 4 * * 4' - - # 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 + + ```
@@ -172,106 +171,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -298,7 +198,7 @@ int main( void ) { ## 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]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b9b9e11..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index 753a2ff..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 `minmax_view_buffer_index`. -*/ -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -void print_version() { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -double tic() { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random double on the interval [0,1]. -* -* @return random double -*/ -double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -double benchmark() { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index 38d96d2..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/minmax-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/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 31431c6..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import minmaxViewBufferIndex from '../docs/types/index'; -export = minmaxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index f4a239a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var s=function(i,v){return function(){return v||i((v={exports:{}}).exports,v),v.exports}};var c=s(function(V,t){ -function q(i,v,n){var e,x,m,a,r;for(e=i.length,x=n,m=n,r=0;r0?m+=a*(i[r]-1):a<0&&(x+=a*(i[r]-1))}return[x,m]}t.exports=q -});var l=s(function(y,d){ -function f(i,v,n,e){var x,m,a,r,u;for(x=i.length,m=n,a=n,u=0;u0?a+=r*(i[u]-1):r<0&&(m+=r*(i[u]-1))}return e[0]=m,e[1]=a,e}d.exports=f -});var w=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),g=c(),B=l();w(g,"assign",B);module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index d90186a..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAuBC,EAAOC,EAASC,EAAS,CACxD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAM,OACdI,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKP,EAAOO,CAAE,IAAM,EACnB,MAAO,CAAEL,EAAQA,CAAO,EAEzBI,EAAIL,EAASM,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMN,EAAMO,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,CAAC,EAAE,GAExB,CACA,MAAO,CAAEH,EAAKC,CAAI,CACnB,CAKAP,EAAO,QAAUC,ICzFjB,IAAAS,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA+EA,SAASC,EAAuBC,EAAOC,EAASC,EAAQC,EAAM,CAC7D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQJ,EAAM,OACdK,EAAMH,EACNI,EAAMJ,EACAM,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKR,EAAOQ,CAAE,IAAM,EACnB,OAAAL,EAAK,CAAE,EAAID,EACXC,EAAK,CAAE,EAAID,EACJC,EAERI,EAAIN,EAASO,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMP,EAAMQ,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMP,EAAMQ,CAAC,EAAE,GAExB,CACA,OAAAL,EAAK,CAAE,EAAIE,EACXF,EAAK,CAAE,EAAIG,EACJH,CACR,CAKAL,EAAO,QAAUC,IC1CjB,IAAIU,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "ndims", "min", "max", "s", "i", "require_assign", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "out", "ndims", "min", "max", "s", "i", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index 32b9185..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 06beab9..67b8519 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..af1ec5b --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7cde065 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index 83b31eb..a118442 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.1.1", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.1.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/utils-library-manifest": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.1.0", - "@stdlib/assert-is-nonnegative-integer-array": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.1.0", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.1.0", - "@stdlib/ndarray-base-shape2strides": "^0.1.0", - "@stdlib/ndarray-base-strides2offset": "^0.1.0", - "@stdlib/random-base-discrete-uniform": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8d8204c --- /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 b75e064..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From 2960fcd8ce1cfd78fa09abbb038e7b4711cfab63 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 4 Oct 2023 15:59:01 +0000 Subject: [PATCH 064/143] Update README.md for ESM bundle v0.1.1 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8ecd607..db34692 100644 --- a/README.md +++ b/README.md @@ -52,13 +52,13 @@ limitations under the License. ## Usage ```javascript -import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs'; +import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.1.1-esm/index.mjs'; ``` You can also import the following named exports from the package: ```javascript -import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs'; +import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.1.1-esm/index.mjs'; ``` #### minmaxViewBufferIndex( shape, strides, offset ) @@ -126,7 +126,7 @@ import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-d import shape2strides from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs'; import strides2offset from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs'; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-randu@esm/index.mjs'; -import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs'; +import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.1.1-esm/index.mjs'; var strides; var offset; From a67017bf932e869f84a1702cd06f303a17b13b20 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 4 Oct 2023 15:59:02 +0000 Subject: [PATCH 065/143] Auto-generated commit --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index db34692..f687415 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tags). For example, + ```javascript import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.1.1-esm/index.mjs'; ``` @@ -58,7 +63,7 @@ import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray You can also import the following named exports from the package: ```javascript -import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.1.1-esm/index.mjs'; +import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs'; ``` #### minmaxViewBufferIndex( shape, strides, offset ) @@ -126,7 +131,7 @@ import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-d import shape2strides from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs'; import strides2offset from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs'; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-randu@esm/index.mjs'; -import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.1.1-esm/index.mjs'; +import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs'; var strides; var offset; From 0a63917d1fe8e7cff292a711aec2f55390d01b2b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 04:57:37 +0000 Subject: [PATCH 066/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b464d7b..b1063a2 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.1.0", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/utils-library-manifest": "^0.1.1" + "@stdlib/utils-library-manifest": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/assert-is-array": "^0.1.1", @@ -100,4 +101,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From eb0f40b3bf93777f3c49ac9e4327b507c41112a3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 22:24:56 +0000 Subject: [PATCH 067/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6252 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 67b8519..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index af1ec5b..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7cde065..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8d8204c..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From f64860c54fe4bf77848acc6226d9d2ebc2aa7cbc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 22:28:07 +0000 Subject: [PATCH 068/143] 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 | 146 +- benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 6177 +++++++++++++++++ test/dist/test.js | 336 - test/test.js | 336 - 49 files changed, 6209 insertions(+), 5360 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c 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/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 94545a8..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/minmax-view-buffer-index) 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 ed2728d..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/minmax-view-buffer-index) 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 e0d7511..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: '40 4 * * 4' - - # 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 + + ```
@@ -172,106 +171,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -298,7 +198,7 @@ int main( void ) { ## 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]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b9b9e11..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index 753a2ff..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 `minmax_view_buffer_index`. -*/ -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -void print_version() { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -double tic() { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random double on the interval [0,1]. -* -* @return random double -*/ -double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -double benchmark() { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index 38d96d2..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/minmax-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/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 31431c6..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import minmaxViewBufferIndex from '../docs/types/index'; -export = minmaxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index f4a239a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var s=function(i,v){return function(){return v||i((v={exports:{}}).exports,v),v.exports}};var c=s(function(V,t){ -function q(i,v,n){var e,x,m,a,r;for(e=i.length,x=n,m=n,r=0;r0?m+=a*(i[r]-1):a<0&&(x+=a*(i[r]-1))}return[x,m]}t.exports=q -});var l=s(function(y,d){ -function f(i,v,n,e){var x,m,a,r,u;for(x=i.length,m=n,a=n,u=0;u0?a+=r*(i[u]-1):r<0&&(m+=r*(i[u]-1))}return e[0]=m,e[1]=a,e}d.exports=f -});var w=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),g=c(),B=l();w(g,"assign",B);module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index d90186a..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAuBC,EAAOC,EAASC,EAAS,CACxD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAM,OACdI,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKP,EAAOO,CAAE,IAAM,EACnB,MAAO,CAAEL,EAAQA,CAAO,EAEzBI,EAAIL,EAASM,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMN,EAAMO,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,CAAC,EAAE,GAExB,CACA,MAAO,CAAEH,EAAKC,CAAI,CACnB,CAKAP,EAAO,QAAUC,ICzFjB,IAAAS,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA+EA,SAASC,EAAuBC,EAAOC,EAASC,EAAQC,EAAM,CAC7D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQJ,EAAM,OACdK,EAAMH,EACNI,EAAMJ,EACAM,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKR,EAAOQ,CAAE,IAAM,EACnB,OAAAL,EAAK,CAAE,EAAID,EACXC,EAAK,CAAE,EAAID,EACJC,EAERI,EAAIN,EAASO,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMP,EAAMQ,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMP,EAAMQ,CAAC,EAAE,GAExB,CACA,OAAAL,EAAK,CAAE,EAAIE,EACXF,EAAK,CAAE,EAAIG,EACJH,CACR,CAKAL,EAAO,QAAUC,IC1CjB,IAAIU,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "ndims", "min", "max", "s", "i", "require_assign", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "out", "ndims", "min", "max", "s", "i", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index 32b9185..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 06beab9..67b8519 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..af1ec5b --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7cde065 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index b1063a2..a118442 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.1.1", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.1.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/utils-library-manifest": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer-array": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.1.1", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/random-base-discrete-uniform": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..08ad0fc --- /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 b75e064..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From 08bf2a27a4f91b9f2e8ead782c2236a4aa292f3f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 02:52:43 +0000 Subject: [PATCH 069/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b464d7b..b1063a2 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.1.0", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/utils-library-manifest": "^0.1.1" + "@stdlib/utils-library-manifest": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/assert-is-array": "^0.1.1", @@ -100,4 +101,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 8bc10eb8defe2b6e72e1c965d3b64cbd69cb31b3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 21:54:09 +0000 Subject: [PATCH 070/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6252 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 67b8519..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index af1ec5b..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7cde065..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 08ad0fc..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 6a809c1f8f05a46c837750e764cd23700d7a1ba0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 21:56:33 +0000 Subject: [PATCH 071/143] 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 | 146 +- benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 6177 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 336 - 50 files changed, 6209 insertions(+), 5066 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c 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/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 117cf0a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-11-01T01:22:43.438Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 94545a8..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/minmax-view-buffer-index) 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 ed2728d..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/minmax-view-buffer-index) 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 e0d7511..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: '40 4 * * 4' - - # 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 + + ```
@@ -172,106 +171,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -298,7 +198,7 @@ int main( void ) { ## 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]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b9b9e11..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index 753a2ff..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 `minmax_view_buffer_index`. -*/ -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -void print_version() { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -double tic() { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random double on the interval [0,1]. -* -* @return random double -*/ -double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -double benchmark() { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index 38d96d2..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/minmax-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/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 31431c6..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import minmaxViewBufferIndex from '../docs/types/index'; -export = minmaxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index f4a239a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var s=function(i,v){return function(){return v||i((v={exports:{}}).exports,v),v.exports}};var c=s(function(V,t){ -function q(i,v,n){var e,x,m,a,r;for(e=i.length,x=n,m=n,r=0;r0?m+=a*(i[r]-1):a<0&&(x+=a*(i[r]-1))}return[x,m]}t.exports=q -});var l=s(function(y,d){ -function f(i,v,n,e){var x,m,a,r,u;for(x=i.length,m=n,a=n,u=0;u0?a+=r*(i[u]-1):r<0&&(m+=r*(i[u]-1))}return e[0]=m,e[1]=a,e}d.exports=f -});var w=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),g=c(),B=l();w(g,"assign",B);module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index d90186a..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAuBC,EAAOC,EAASC,EAAS,CACxD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAM,OACdI,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKP,EAAOO,CAAE,IAAM,EACnB,MAAO,CAAEL,EAAQA,CAAO,EAEzBI,EAAIL,EAASM,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMN,EAAMO,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,CAAC,EAAE,GAExB,CACA,MAAO,CAAEH,EAAKC,CAAI,CACnB,CAKAP,EAAO,QAAUC,ICzFjB,IAAAS,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA+EA,SAASC,EAAuBC,EAAOC,EAASC,EAAQC,EAAM,CAC7D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQJ,EAAM,OACdK,EAAMH,EACNI,EAAMJ,EACAM,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKR,EAAOQ,CAAE,IAAM,EACnB,OAAAL,EAAK,CAAE,EAAID,EACXC,EAAK,CAAE,EAAID,EACJC,EAERI,EAAIN,EAASO,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMP,EAAMQ,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMP,EAAMQ,CAAC,EAAE,GAExB,CACA,OAAAL,EAAK,CAAE,EAAIE,EACXF,EAAK,CAAE,EAAIG,EACJH,CACR,CAKAL,EAAO,QAAUC,IC1CjB,IAAIU,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "ndims", "min", "max", "s", "i", "require_assign", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "out", "ndims", "min", "max", "s", "i", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index 32b9185..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 06beab9..67b8519 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..af1ec5b --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7cde065 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index b1063a2..a118442 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.1.1", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.1.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/utils-library-manifest": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer-array": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.1.1", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/random-base-discrete-uniform": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..9005d71 --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From db9539d815860418cfa1c8c63fd9d2706f4f27b1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 02:46:16 +0000 Subject: [PATCH 072/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 7c83bdd..d03a602 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.2.0", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/utils-library-manifest": "^0.1.1" + "@stdlib/utils-library-manifest": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/assert-is-array": "^0.1.1", @@ -100,4 +101,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From e58441267501cae38e103c816883f5c6337fa483 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 14:38:45 +0000 Subject: [PATCH 073/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6252 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 67b8519..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index af1ec5b..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7cde065..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 9005d71..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From fdfca91a596cc85491d2cb2b5055304d030c49e4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 14:41:25 +0000 Subject: [PATCH 074/143] 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 | 146 +- benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 6177 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 336 - 50 files changed, 6209 insertions(+), 5061 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c 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/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 a3f77f9..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-12-01T01:27:15.508Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 94545a8..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/minmax-view-buffer-index) 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 ed2728d..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/minmax-view-buffer-index) 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 e0d7511..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: '40 4 * * 4' - - # 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 + + ```
@@ -172,106 +171,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -298,7 +198,7 @@ int main( void ) { ## 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]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b9b9e11..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index 753a2ff..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 `minmax_view_buffer_index`. -*/ -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -void print_version() { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -double tic() { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random double on the interval [0,1]. -* -* @return random double -*/ -double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -double benchmark() { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index 38d96d2..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/minmax-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/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 31431c6..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import minmaxViewBufferIndex from '../docs/types/index'; -export = minmaxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index f4a239a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var s=function(i,v){return function(){return v||i((v={exports:{}}).exports,v),v.exports}};var c=s(function(V,t){ -function q(i,v,n){var e,x,m,a,r;for(e=i.length,x=n,m=n,r=0;r0?m+=a*(i[r]-1):a<0&&(x+=a*(i[r]-1))}return[x,m]}t.exports=q -});var l=s(function(y,d){ -function f(i,v,n,e){var x,m,a,r,u;for(x=i.length,m=n,a=n,u=0;u0?a+=r*(i[u]-1):r<0&&(m+=r*(i[u]-1))}return e[0]=m,e[1]=a,e}d.exports=f -});var w=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),g=c(),B=l();w(g,"assign",B);module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index d90186a..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAuBC,EAAOC,EAASC,EAAS,CACxD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAM,OACdI,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKP,EAAOO,CAAE,IAAM,EACnB,MAAO,CAAEL,EAAQA,CAAO,EAEzBI,EAAIL,EAASM,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMN,EAAMO,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,CAAC,EAAE,GAExB,CACA,MAAO,CAAEH,EAAKC,CAAI,CACnB,CAKAP,EAAO,QAAUC,ICzFjB,IAAAS,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA+EA,SAASC,EAAuBC,EAAOC,EAASC,EAAQC,EAAM,CAC7D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQJ,EAAM,OACdK,EAAMH,EACNI,EAAMJ,EACAM,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKR,EAAOQ,CAAE,IAAM,EACnB,OAAAL,EAAK,CAAE,EAAID,EACXC,EAAK,CAAE,EAAID,EACJC,EAERI,EAAIN,EAASO,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMP,EAAMQ,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMP,EAAMQ,CAAC,EAAE,GAExB,CACA,OAAAL,EAAK,CAAE,EAAIE,EACXF,EAAK,CAAE,EAAIG,EACJH,CACR,CAKAL,EAAO,QAAUC,IC1CjB,IAAIU,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "ndims", "min", "max", "s", "i", "require_assign", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "out", "ndims", "min", "max", "s", "i", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index 32b9185..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index b116911..757108e 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..af1ec5b --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7cde065 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index d03a602..a118442 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.1.1", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.2.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/utils-library-manifest": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer-array": "^0.1.0", - "@stdlib/bench": "^0.2.1", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.1.1", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/random-base-discrete-uniform": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..62b85f5 --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From 86963a10907aa7c61cafedffa0518f6f52da0a3a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 02:05:17 +0000 Subject: [PATCH 075/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b581a97..9c68cda 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.2.0", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/utils-library-manifest": "^0.1.1" + "@stdlib/utils-library-manifest": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/assert-is-array": "^0.1.1", @@ -100,4 +101,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From bb499784b6789e32bb8096761de65e96fbae4910 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 05:36:34 +0000 Subject: [PATCH 076/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6252 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 757108e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index af1ec5b..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7cde065..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 62b85f5..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 3be8f5829547bf8e0e66589172042593242c8e78 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 05:36:54 +0000 Subject: [PATCH 077/143] 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 | 146 +- SECURITY.md | 5 - benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 6177 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 336 - 51 files changed, 6209 insertions(+), 5067 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c 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/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 85d3797..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-01-01T01:20:04.238Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 94545a8..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/minmax-view-buffer-index) 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 ed2728d..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/minmax-view-buffer-index) 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 2cbaf94..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: '40 4 * * 4' - - # 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 + + ```
@@ -172,106 +171,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -298,7 +198,7 @@ int main( void ) { ## 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]. 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 9d0db67..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index 753a2ff..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 `minmax_view_buffer_index`. -*/ -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -void print_version() { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -double tic() { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random double on the interval [0,1]. -* -* @return random double -*/ -double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -double benchmark() { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index 38d96d2..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/minmax-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/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 31431c6..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import minmaxViewBufferIndex from '../docs/types/index'; -export = minmaxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index f4a239a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var s=function(i,v){return function(){return v||i((v={exports:{}}).exports,v),v.exports}};var c=s(function(V,t){ -function q(i,v,n){var e,x,m,a,r;for(e=i.length,x=n,m=n,r=0;r0?m+=a*(i[r]-1):a<0&&(x+=a*(i[r]-1))}return[x,m]}t.exports=q -});var l=s(function(y,d){ -function f(i,v,n,e){var x,m,a,r,u;for(x=i.length,m=n,a=n,u=0;u0?a+=r*(i[u]-1):r<0&&(m+=r*(i[u]-1))}return e[0]=m,e[1]=a,e}d.exports=f -});var w=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),g=c(),B=l();w(g,"assign",B);module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index d90186a..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAuBC,EAAOC,EAASC,EAAS,CACxD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAM,OACdI,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKP,EAAOO,CAAE,IAAM,EACnB,MAAO,CAAEL,EAAQA,CAAO,EAEzBI,EAAIL,EAASM,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMN,EAAMO,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,CAAC,EAAE,GAExB,CACA,MAAO,CAAEH,EAAKC,CAAI,CACnB,CAKAP,EAAO,QAAUC,ICzFjB,IAAAS,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA+EA,SAASC,EAAuBC,EAAOC,EAASC,EAAQC,EAAM,CAC7D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQJ,EAAM,OACdK,EAAMH,EACNI,EAAMJ,EACAM,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKR,EAAOQ,CAAE,IAAM,EACnB,OAAAL,EAAK,CAAE,EAAID,EACXC,EAAK,CAAE,EAAID,EACJC,EAERI,EAAIN,EAASO,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMP,EAAMQ,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMP,EAAMQ,CAAC,EAAE,GAExB,CACA,OAAAL,EAAK,CAAE,EAAIE,EACXF,EAAK,CAAE,EAAIG,EACJH,CACR,CAKAL,EAAO,QAAUC,IC1CjB,IAAIU,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "ndims", "min", "max", "s", "i", "require_assign", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "out", "ndims", "min", "max", "s", "i", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index 32b9185..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index b116911..757108e 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..2c531ef --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7cde065 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index 9c68cda..a118442 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.1.1", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.2.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/utils-library-manifest": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer-array": "^0.1.0", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.1.1", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/random-base-discrete-uniform": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2f8204d --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From 93a41540638abeae8f59aa9729d5f980263de08f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 02:07:35 +0000 Subject: [PATCH 078/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b581a97..9c68cda 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.2.0", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/utils-library-manifest": "^0.1.1" + "@stdlib/utils-library-manifest": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/assert-is-array": "^0.1.1", @@ -100,4 +101,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 75db334758b84592aaa239303fe98b4e23418057 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 04:44:50 +0000 Subject: [PATCH 079/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6252 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 757108e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2c531ef..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7cde065..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2f8204d..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e8a37ab326038f12ed86f69f4823dc470f75032f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 04:45:16 +0000 Subject: [PATCH 080/143] 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 | 148 +- SECURITY.md | 5 - benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 6177 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 336 - 51 files changed, 6209 insertions(+), 5072 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c 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/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 255b9f2..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-02-01T01:28:10.103Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 94545a8..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/minmax-view-buffer-index) 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 ed2728d..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/minmax-view-buffer-index) 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 2cbaf94..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: '40 4 * * 4' - - # 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 + + ```
@@ -174,106 +171,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -300,7 +198,7 @@ int main( void ) { ## 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]. 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 9d0db67..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index 753a2ff..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 `minmax_view_buffer_index`. -*/ -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -void print_version() { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -double tic() { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random double on the interval [0,1]. -* -* @return random double -*/ -double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -double benchmark() { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index d4659bb..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/minmax-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/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 31431c6..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import minmaxViewBufferIndex from '../docs/types/index'; -export = minmaxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index f4a239a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var s=function(i,v){return function(){return v||i((v={exports:{}}).exports,v),v.exports}};var c=s(function(V,t){ -function q(i,v,n){var e,x,m,a,r;for(e=i.length,x=n,m=n,r=0;r0?m+=a*(i[r]-1):a<0&&(x+=a*(i[r]-1))}return[x,m]}t.exports=q -});var l=s(function(y,d){ -function f(i,v,n,e){var x,m,a,r,u;for(x=i.length,m=n,a=n,u=0;u0?a+=r*(i[u]-1):r<0&&(m+=r*(i[u]-1))}return e[0]=m,e[1]=a,e}d.exports=f -});var w=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),g=c(),B=l();w(g,"assign",B);module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index d90186a..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAuBC,EAAOC,EAASC,EAAS,CACxD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAM,OACdI,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKP,EAAOO,CAAE,IAAM,EACnB,MAAO,CAAEL,EAAQA,CAAO,EAEzBI,EAAIL,EAASM,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMN,EAAMO,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,CAAC,EAAE,GAExB,CACA,MAAO,CAAEH,EAAKC,CAAI,CACnB,CAKAP,EAAO,QAAUC,ICzFjB,IAAAS,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA+EA,SAASC,EAAuBC,EAAOC,EAASC,EAAQC,EAAM,CAC7D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQJ,EAAM,OACdK,EAAMH,EACNI,EAAMJ,EACAM,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKR,EAAOQ,CAAE,IAAM,EACnB,OAAAL,EAAK,CAAE,EAAID,EACXC,EAAK,CAAE,EAAID,EACJC,EAERI,EAAIN,EAASO,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMP,EAAMQ,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMP,EAAMQ,CAAC,EAAE,GAExB,CACA,OAAAL,EAAK,CAAE,EAAIE,EACXF,EAAK,CAAE,EAAIG,EACJH,CACR,CAKAL,EAAO,QAAUC,IC1CjB,IAAIU,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "ndims", "min", "max", "s", "i", "require_assign", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "out", "ndims", "min", "max", "s", "i", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index 32b9185..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index b116911..757108e 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..2c531ef --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7cde065 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index 9c68cda..a118442 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.1.1", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.2.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/utils-library-manifest": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer-array": "^0.1.0", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.1.1", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/random-base-discrete-uniform": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..db352a3 --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From c2ea37b9f53e355aa39a242a8954c482b084afa0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 05:08:21 +0000 Subject: [PATCH 081/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4fb9130..b8f5a2b 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.3.1", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.0", - "@stdlib/utils-library-manifest": "^0.2.0" + "@stdlib/utils-library-manifest": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.2.0" }, "devDependencies": { "@stdlib/assert-is-array": "^0.1.1", @@ -100,4 +101,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From bd552c9f81e27db4469a8f03feb1bed394c59015 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 07:46:03 +0000 Subject: [PATCH 082/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6252 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 757108e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2c531ef..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7cde065..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index db352a3..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 592b781df890cd6eb6a4421ee7188605e4c4294d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 07:46:34 +0000 Subject: [PATCH 083/143] 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 | 148 +- SECURITY.md | 5 - benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 6177 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 336 - 50 files changed, 6209 insertions(+), 5075 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c 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/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 94545a8..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/minmax-view-buffer-index) 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 ed2728d..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/minmax-view-buffer-index) 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 e7b9095..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: '40 4 * * 4' - - # 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 + + ```
@@ -174,106 +171,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -300,7 +198,7 @@ int main( void ) { ## 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]. 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 9d0db67..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index 753a2ff..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 `minmax_view_buffer_index`. -*/ -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -void print_version() { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -double tic() { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random double on the interval [0,1]. -* -* @return random double -*/ -double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -double benchmark() { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index d4659bb..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/minmax-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/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 31431c6..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import minmaxViewBufferIndex from '../docs/types/index'; -export = minmaxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index f4a239a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var s=function(i,v){return function(){return v||i((v={exports:{}}).exports,v),v.exports}};var c=s(function(V,t){ -function q(i,v,n){var e,x,m,a,r;for(e=i.length,x=n,m=n,r=0;r0?m+=a*(i[r]-1):a<0&&(x+=a*(i[r]-1))}return[x,m]}t.exports=q -});var l=s(function(y,d){ -function f(i,v,n,e){var x,m,a,r,u;for(x=i.length,m=n,a=n,u=0;u0?a+=r*(i[u]-1):r<0&&(m+=r*(i[u]-1))}return e[0]=m,e[1]=a,e}d.exports=f -});var w=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),g=c(),B=l();w(g,"assign",B);module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index d90186a..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAuBC,EAAOC,EAASC,EAAS,CACxD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAM,OACdI,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKP,EAAOO,CAAE,IAAM,EACnB,MAAO,CAAEL,EAAQA,CAAO,EAEzBI,EAAIL,EAASM,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMN,EAAMO,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,CAAC,EAAE,GAExB,CACA,MAAO,CAAEH,EAAKC,CAAI,CACnB,CAKAP,EAAO,QAAUC,ICzFjB,IAAAS,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA+EA,SAASC,EAAuBC,EAAOC,EAASC,EAAQC,EAAM,CAC7D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQJ,EAAM,OACdK,EAAMH,EACNI,EAAMJ,EACAM,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKR,EAAOQ,CAAE,IAAM,EACnB,OAAAL,EAAK,CAAE,EAAID,EACXC,EAAK,CAAE,EAAID,EACJC,EAERI,EAAIN,EAASO,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMP,EAAMQ,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMP,EAAMQ,CAAC,EAAE,GAExB,CACA,OAAAL,EAAK,CAAE,EAAIE,EACXF,EAAK,CAAE,EAAIG,EACJH,CACR,CAKAL,EAAO,QAAUC,IC1CjB,IAAIU,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "ndims", "min", "max", "s", "i", "require_assign", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "out", "ndims", "min", "max", "s", "i", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index 32b9185..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index b116911..757108e 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..2c531ef --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7cde065 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index b8f5a2b..2d8002b 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.2.0", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.3.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.0", - "@stdlib/utils-library-manifest": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.0" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer-array": "^0.1.0", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.1.1", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/random-base-discrete-uniform": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..fbb75ce --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From a665f4bb54cb6c89a30e2ae8b6e69e2721d58d6c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 11:04:58 +0000 Subject: [PATCH 084/143] Update README.md for ESM bundle v0.2.0 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index fbef048..ad76d7b 100644 --- a/README.md +++ b/README.md @@ -52,13 +52,13 @@ limitations under the License. ## Usage ```javascript -import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs'; +import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.0-esm/index.mjs'; ``` You can also import the following named exports from the package: ```javascript -import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs'; +import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.0-esm/index.mjs'; ``` #### minmaxViewBufferIndex( shape, strides, offset ) @@ -126,7 +126,7 @@ import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-d import shape2strides from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs'; import strides2offset from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs'; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-randu@esm/index.mjs'; -import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs'; +import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.0-esm/index.mjs'; var strides; var offset; From 4be70c508b0576d30dc878af8f951e19d4fd28af Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 11:04:58 +0000 Subject: [PATCH 085/143] Auto-generated commit --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ad76d7b..95aef3c 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tags). For example, + ```javascript import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.0-esm/index.mjs'; ``` @@ -58,7 +63,7 @@ import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray You can also import the following named exports from the package: ```javascript -import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.0-esm/index.mjs'; +import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs'; ``` #### minmaxViewBufferIndex( shape, strides, offset ) @@ -126,7 +131,7 @@ import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-d import shape2strides from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs'; import strides2offset from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs'; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-randu@esm/index.mjs'; -import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.0-esm/index.mjs'; +import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs'; var strides; var offset; From d06ef9143a4b8194f6f2f57eba6b3a519c317fe4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 22 Feb 2024 02:13:50 +0000 Subject: [PATCH 086/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 013b8db..643df5d 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.3.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/utils-library-manifest": "^0.2.1" + "@stdlib/utils-library-manifest": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/assert-is-array": "^0.2.1", @@ -100,4 +101,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From b78817e4a10bc048ec909756759f0e58fd585ad6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 22 Feb 2024 03:38:51 +0000 Subject: [PATCH 087/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6252 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 757108e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2c531ef..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7cde065..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index fbb75ce..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 25d9e5526cb5aaada8358367ccb1e499d732112f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 22 Feb 2024 03:40:32 +0000 Subject: [PATCH 088/143] 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 | 148 +- SECURITY.md | 5 - benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 336 -- 50 files changed, 4874 insertions(+), 5069 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c 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/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 94545a8..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/minmax-view-buffer-index) 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 ed2728d..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/minmax-view-buffer-index) 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 6eaad2f..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: '40 4 * * 4' - - # 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 + + ```
@@ -174,106 +171,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -300,7 +198,7 @@ int main( void ) { ## 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]. 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 9d0db67..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index 753a2ff..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 `minmax_view_buffer_index`. -*/ -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -void print_version() { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -double tic() { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random double on the interval [0,1]. -* -* @return random double -*/ -double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -double benchmark() { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index d4659bb..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/minmax-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/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 31431c6..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import minmaxViewBufferIndex from '../docs/types/index'; -export = minmaxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index f4a239a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var s=function(i,v){return function(){return v||i((v={exports:{}}).exports,v),v.exports}};var c=s(function(V,t){ -function q(i,v,n){var e,x,m,a,r;for(e=i.length,x=n,m=n,r=0;r0?m+=a*(i[r]-1):a<0&&(x+=a*(i[r]-1))}return[x,m]}t.exports=q -});var l=s(function(y,d){ -function f(i,v,n,e){var x,m,a,r,u;for(x=i.length,m=n,a=n,u=0;u0?a+=r*(i[u]-1):r<0&&(m+=r*(i[u]-1))}return e[0]=m,e[1]=a,e}d.exports=f -});var w=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),g=c(),B=l();w(g,"assign",B);module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index d90186a..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAuBC,EAAOC,EAASC,EAAS,CACxD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAM,OACdI,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKP,EAAOO,CAAE,IAAM,EACnB,MAAO,CAAEL,EAAQA,CAAO,EAEzBI,EAAIL,EAASM,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMN,EAAMO,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,CAAC,EAAE,GAExB,CACA,MAAO,CAAEH,EAAKC,CAAI,CACnB,CAKAP,EAAO,QAAUC,ICzFjB,IAAAS,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA+EA,SAASC,EAAuBC,EAAOC,EAASC,EAAQC,EAAM,CAC7D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQJ,EAAM,OACdK,EAAMH,EACNI,EAAMJ,EACAM,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKR,EAAOQ,CAAE,IAAM,EACnB,OAAAL,EAAK,CAAE,EAAID,EACXC,EAAK,CAAE,EAAID,EACJC,EAERI,EAAIN,EAASO,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMP,EAAMQ,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMP,EAAMQ,CAAC,EAAE,GAExB,CACA,OAAAL,EAAK,CAAE,EAAIE,EACXF,EAAK,CAAE,EAAIG,EACJH,CACR,CAKAL,EAAO,QAAUC,IC1CjB,IAAIU,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "ndims", "min", "max", "s", "i", "require_assign", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "out", "ndims", "min", "max", "s", "i", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index 32b9185..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index b116911..757108e 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..46a79e6 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7cde065 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index 643df5d..cf3e431 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.2.1", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/utils-library-manifest": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer-array": "^0.2.0", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.2.0", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.2.0", - "@stdlib/ndarray-base-shape2strides": "^0.2.0", - "@stdlib/ndarray-base-strides2offset": "^0.2.0", - "@stdlib/random-base-discrete-uniform": "^0.2.0", - "@stdlib/random-base-randu": "^0.2.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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b00d034 --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From a51f963621bd8f61f3cb91370c7b943433b4b732 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 22 Feb 2024 03:56:06 +0000 Subject: [PATCH 089/143] Update README.md for ESM bundle v0.2.1 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index da28b26..7344c3b 100644 --- a/README.md +++ b/README.md @@ -52,13 +52,13 @@ limitations under the License. ## Usage ```javascript -import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs'; +import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.1-esm/index.mjs'; ``` You can also import the following named exports from the package: ```javascript -import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs'; +import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.1-esm/index.mjs'; ``` #### minmaxViewBufferIndex( shape, strides, offset ) @@ -126,7 +126,7 @@ import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-d import shape2strides from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs'; import strides2offset from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs'; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-randu@esm/index.mjs'; -import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs'; +import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.1-esm/index.mjs'; var strides; var offset; From 826b2c9e286961986478b633862531d91bc687a6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 22 Feb 2024 03:56:06 +0000 Subject: [PATCH 090/143] Auto-generated commit --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7344c3b..e16cb4e 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tags). For example, + ```javascript import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.1-esm/index.mjs'; ``` @@ -58,7 +63,7 @@ import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray You can also import the following named exports from the package: ```javascript -import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.1-esm/index.mjs'; +import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs'; ``` #### minmaxViewBufferIndex( shape, strides, offset ) @@ -126,7 +131,7 @@ import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-d import shape2strides from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs'; import strides2offset from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs'; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-randu@esm/index.mjs'; -import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.1-esm/index.mjs'; +import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs'; var strides; var offset; From 07c90866d893b7a07f11ed64ca5e09419306314a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 01:54:42 +0000 Subject: [PATCH 091/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index faa0c6f..d970542 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.3.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/utils-library-manifest": "^0.2.1" + "@stdlib/utils-library-manifest": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/assert-is-array": "^0.2.1", @@ -100,4 +101,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From cabc18426fc8601a0f4eb5575dc2f60d70a42d55 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 03:35:19 +0000 Subject: [PATCH 092/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4917 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 757108e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 46a79e6..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7cde065..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b00d034..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 4f4556cd34cd205e4882860092dc495f50e58229 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 03:35:35 +0000 Subject: [PATCH 093/143] 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 | 148 +- SECURITY.md | 5 - benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 336 -- 51 files changed, 4874 insertions(+), 5071 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c 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/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 1a280df..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-03-01T01:28:06.084Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 94545a8..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/minmax-view-buffer-index) 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 ed2728d..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/minmax-view-buffer-index) 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 6eaad2f..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: '40 4 * * 4' - - # 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 + + ```
@@ -174,106 +171,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -300,7 +198,7 @@ int main( void ) { ## 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]. 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 9d0db67..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index 753a2ff..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 `minmax_view_buffer_index`. -*/ -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -void print_version() { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -double tic() { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random double on the interval [0,1]. -* -* @return random double -*/ -double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -double benchmark() { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index d4659bb..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/minmax-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/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 31431c6..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import minmaxViewBufferIndex from '../docs/types/index'; -export = minmaxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index f4a239a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var s=function(i,v){return function(){return v||i((v={exports:{}}).exports,v),v.exports}};var c=s(function(V,t){ -function q(i,v,n){var e,x,m,a,r;for(e=i.length,x=n,m=n,r=0;r0?m+=a*(i[r]-1):a<0&&(x+=a*(i[r]-1))}return[x,m]}t.exports=q -});var l=s(function(y,d){ -function f(i,v,n,e){var x,m,a,r,u;for(x=i.length,m=n,a=n,u=0;u0?a+=r*(i[u]-1):r<0&&(m+=r*(i[u]-1))}return e[0]=m,e[1]=a,e}d.exports=f -});var w=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),g=c(),B=l();w(g,"assign",B);module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index d90186a..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAuBC,EAAOC,EAASC,EAAS,CACxD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAM,OACdI,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKP,EAAOO,CAAE,IAAM,EACnB,MAAO,CAAEL,EAAQA,CAAO,EAEzBI,EAAIL,EAASM,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMN,EAAMO,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,CAAC,EAAE,GAExB,CACA,MAAO,CAAEH,EAAKC,CAAI,CACnB,CAKAP,EAAO,QAAUC,ICzFjB,IAAAS,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA+EA,SAASC,EAAuBC,EAAOC,EAASC,EAAQC,EAAM,CAC7D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQJ,EAAM,OACdK,EAAMH,EACNI,EAAMJ,EACAM,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKR,EAAOQ,CAAE,IAAM,EACnB,OAAAL,EAAK,CAAE,EAAID,EACXC,EAAK,CAAE,EAAID,EACJC,EAERI,EAAIN,EAASO,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMP,EAAMQ,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMP,EAAMQ,CAAC,EAAE,GAExB,CACA,OAAAL,EAAK,CAAE,EAAIE,EACXF,EAAK,CAAE,EAAIG,EACJH,CACR,CAKAL,EAAO,QAAUC,IC1CjB,IAAIU,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "ndims", "min", "max", "s", "i", "require_assign", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "out", "ndims", "min", "max", "s", "i", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index 32b9185..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index b116911..757108e 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..46a79e6 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7cde065 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index d970542..cf3e431 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.2.1", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/utils-library-manifest": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer-array": "^0.2.1", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.2.1", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.2.1", - "@stdlib/ndarray-base-shape2strides": "^0.2.1", - "@stdlib/ndarray-base-strides2offset": "^0.2.1", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b00d034 --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From 116e45f1622c73c7067cc9e5af7a5726afe2c861 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 01:44:51 +0000 Subject: [PATCH 094/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index faa0c6f..d970542 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.3.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/utils-library-manifest": "^0.2.1" + "@stdlib/utils-library-manifest": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/assert-is-array": "^0.2.1", @@ -100,4 +101,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 48c41730989b65ccec345fb275720f9bcd40cb07 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 03:55:02 +0000 Subject: [PATCH 095/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4917 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 757108e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 46a79e6..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7cde065..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b00d034..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 8ed11fb92f086c3bf14ac59b24a88245ff85843a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 03:55:15 +0000 Subject: [PATCH 096/143] 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 | 148 +- SECURITY.md | 5 - benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 336 -- 51 files changed, 4874 insertions(+), 5074 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c 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/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 ebf7f3d..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T01:15:43.277Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 94545a8..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/minmax-view-buffer-index) 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 ed2728d..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/minmax-view-buffer-index) 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 6eaad2f..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: '40 4 * * 4' - - # 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 + + ```
@@ -174,106 +171,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -300,7 +198,7 @@ int main( void ) { ## 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]. 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 9d0db67..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index 753a2ff..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 `minmax_view_buffer_index`. -*/ -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -void print_version() { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -double tic() { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random double on the interval [0,1]. -* -* @return random double -*/ -double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -double benchmark() { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index d4659bb..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/minmax-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/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 31431c6..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import minmaxViewBufferIndex from '../docs/types/index'; -export = minmaxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index f4a239a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var s=function(i,v){return function(){return v||i((v={exports:{}}).exports,v),v.exports}};var c=s(function(V,t){ -function q(i,v,n){var e,x,m,a,r;for(e=i.length,x=n,m=n,r=0;r0?m+=a*(i[r]-1):a<0&&(x+=a*(i[r]-1))}return[x,m]}t.exports=q -});var l=s(function(y,d){ -function f(i,v,n,e){var x,m,a,r,u;for(x=i.length,m=n,a=n,u=0;u0?a+=r*(i[u]-1):r<0&&(m+=r*(i[u]-1))}return e[0]=m,e[1]=a,e}d.exports=f -});var w=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),g=c(),B=l();w(g,"assign",B);module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index d90186a..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAuBC,EAAOC,EAASC,EAAS,CACxD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAM,OACdI,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKP,EAAOO,CAAE,IAAM,EACnB,MAAO,CAAEL,EAAQA,CAAO,EAEzBI,EAAIL,EAASM,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMN,EAAMO,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,CAAC,EAAE,GAExB,CACA,MAAO,CAAEH,EAAKC,CAAI,CACnB,CAKAP,EAAO,QAAUC,ICzFjB,IAAAS,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA+EA,SAASC,EAAuBC,EAAOC,EAASC,EAAQC,EAAM,CAC7D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQJ,EAAM,OACdK,EAAMH,EACNI,EAAMJ,EACAM,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKR,EAAOQ,CAAE,IAAM,EACnB,OAAAL,EAAK,CAAE,EAAID,EACXC,EAAK,CAAE,EAAID,EACJC,EAERI,EAAIN,EAASO,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMP,EAAMQ,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMP,EAAMQ,CAAC,EAAE,GAExB,CACA,OAAAL,EAAK,CAAE,EAAIE,EACXF,EAAK,CAAE,EAAIG,EACJH,CACR,CAKAL,EAAO,QAAUC,IC1CjB,IAAIU,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "ndims", "min", "max", "s", "i", "require_assign", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "out", "ndims", "min", "max", "s", "i", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index 32b9185..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index b116911..757108e 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..46a79e6 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7cde065 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index d970542..cf3e431 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.2.1", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/utils-library-manifest": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer-array": "^0.2.1", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.2.1", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.2.1", - "@stdlib/ndarray-base-shape2strides": "^0.2.1", - "@stdlib/ndarray-base-strides2offset": "^0.2.1", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b00d034 --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From 6c9e3e76d4128ba01888f01b8e8f56e9241e8687 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 11 Apr 2024 21:50:30 +0000 Subject: [PATCH 097/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index faa0c6f..d970542 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.3.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/utils-library-manifest": "^0.2.1" + "@stdlib/utils-library-manifest": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/assert-is-array": "^0.2.1", @@ -100,4 +101,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From bee2334e84896c1efce33a12dd32d9b35e0f5792 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 11 Apr 2024 23:53:24 +0000 Subject: [PATCH 098/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4917 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 757108e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 46a79e6..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7cde065..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b00d034..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 8a31bbe2d6e8012d1994ab919ea26c180dc335c1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 11 Apr 2024 23:53:38 +0000 Subject: [PATCH 099/143] 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 | 148 +- SECURITY.md | 5 - benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 336 -- 50 files changed, 4874 insertions(+), 5075 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c 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/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 94545a8..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/minmax-view-buffer-index) 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 ed2728d..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/minmax-view-buffer-index) 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 6eaad2f..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: '40 4 * * 4' - - # 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 + + ```
@@ -174,106 +171,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -300,7 +198,7 @@ int main( void ) { ## 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]. 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 9d0db67..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index 753a2ff..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 `minmax_view_buffer_index`. -*/ -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -void print_version() { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -double tic() { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random double on the interval [0,1]. -* -* @return random double -*/ -double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -double benchmark() { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index d4659bb..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/minmax-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/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 31431c6..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import minmaxViewBufferIndex from '../docs/types/index'; -export = minmaxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index f4a239a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var s=function(i,v){return function(){return v||i((v={exports:{}}).exports,v),v.exports}};var c=s(function(V,t){ -function q(i,v,n){var e,x,m,a,r;for(e=i.length,x=n,m=n,r=0;r0?m+=a*(i[r]-1):a<0&&(x+=a*(i[r]-1))}return[x,m]}t.exports=q -});var l=s(function(y,d){ -function f(i,v,n,e){var x,m,a,r,u;for(x=i.length,m=n,a=n,u=0;u0?a+=r*(i[u]-1):r<0&&(m+=r*(i[u]-1))}return e[0]=m,e[1]=a,e}d.exports=f -});var w=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),g=c(),B=l();w(g,"assign",B);module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index d90186a..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAuBC,EAAOC,EAASC,EAAS,CACxD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAM,OACdI,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKP,EAAOO,CAAE,IAAM,EACnB,MAAO,CAAEL,EAAQA,CAAO,EAEzBI,EAAIL,EAASM,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMN,EAAMO,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,CAAC,EAAE,GAExB,CACA,MAAO,CAAEH,EAAKC,CAAI,CACnB,CAKAP,EAAO,QAAUC,ICzFjB,IAAAS,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA+EA,SAASC,EAAuBC,EAAOC,EAASC,EAAQC,EAAM,CAC7D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQJ,EAAM,OACdK,EAAMH,EACNI,EAAMJ,EACAM,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKR,EAAOQ,CAAE,IAAM,EACnB,OAAAL,EAAK,CAAE,EAAID,EACXC,EAAK,CAAE,EAAID,EACJC,EAERI,EAAIN,EAASO,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMP,EAAMQ,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMP,EAAMQ,CAAC,EAAE,GAExB,CACA,OAAAL,EAAK,CAAE,EAAIE,EACXF,EAAK,CAAE,EAAIG,EACJH,CACR,CAKAL,EAAO,QAAUC,IC1CjB,IAAIU,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "ndims", "min", "max", "s", "i", "require_assign", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "out", "ndims", "min", "max", "s", "i", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index 32b9185..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index b116911..757108e 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..46a79e6 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7cde065 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index d970542..cf3e431 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.2.1", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/utils-library-manifest": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer-array": "^0.2.1", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.2.1", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.2.1", - "@stdlib/ndarray-base-shape2strides": "^0.2.1", - "@stdlib/ndarray-base-strides2offset": "^0.2.1", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b00d034 --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From be5aebed35961400ba018a04a04a8167cff0d1cb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 May 2024 01:45:11 +0000 Subject: [PATCH 100/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index faa0c6f..d970542 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.3.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/utils-library-manifest": "^0.2.1" + "@stdlib/utils-library-manifest": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/assert-is-array": "^0.2.1", @@ -100,4 +101,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 694f04bcfbc47a6a3a0d3c9f78a5f21008c68f6f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 May 2024 03:18:58 +0000 Subject: [PATCH 101/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4917 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 757108e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 46a79e6..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7cde065..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b00d034..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 557cf49baaefb02cdd3556cc3c6105a724ee29ef Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 May 2024 03:19:23 +0000 Subject: [PATCH 102/143] 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 | 248 - .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 | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 148 +- SECURITY.md | 5 - benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 336 -- 51 files changed, 4874 insertions(+), 5083 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c 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/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 ad837e0..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-05-01T01:16:28.100Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 94545a8..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/minmax-view-buffer-index) 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 ed2728d..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/minmax-view-buffer-index) 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 6eaad2f..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: '40 4 * * 4' - - # 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 f92a6c5..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 + + ```
@@ -174,106 +171,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -300,7 +198,7 @@ int main( void ) { ## 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]. 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 9d0db67..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index 753a2ff..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 `minmax_view_buffer_index`. -*/ -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -void print_version() { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -double tic() { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random double on the interval [0,1]. -* -* @return random double -*/ -double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -double benchmark() { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index d4659bb..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/minmax-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/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 31431c6..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import minmaxViewBufferIndex from '../docs/types/index'; -export = minmaxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index f4a239a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var s=function(i,v){return function(){return v||i((v={exports:{}}).exports,v),v.exports}};var c=s(function(V,t){ -function q(i,v,n){var e,x,m,a,r;for(e=i.length,x=n,m=n,r=0;r0?m+=a*(i[r]-1):a<0&&(x+=a*(i[r]-1))}return[x,m]}t.exports=q -});var l=s(function(y,d){ -function f(i,v,n,e){var x,m,a,r,u;for(x=i.length,m=n,a=n,u=0;u0?a+=r*(i[u]-1):r<0&&(m+=r*(i[u]-1))}return e[0]=m,e[1]=a,e}d.exports=f -});var w=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),g=c(),B=l();w(g,"assign",B);module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index d90186a..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAuBC,EAAOC,EAASC,EAAS,CACxD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAM,OACdI,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKP,EAAOO,CAAE,IAAM,EACnB,MAAO,CAAEL,EAAQA,CAAO,EAEzBI,EAAIL,EAASM,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMN,EAAMO,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,CAAC,EAAE,GAExB,CACA,MAAO,CAAEH,EAAKC,CAAI,CACnB,CAKAP,EAAO,QAAUC,ICzFjB,IAAAS,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA+EA,SAASC,EAAuBC,EAAOC,EAASC,EAAQC,EAAM,CAC7D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQJ,EAAM,OACdK,EAAMH,EACNI,EAAMJ,EACAM,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKR,EAAOQ,CAAE,IAAM,EACnB,OAAAL,EAAK,CAAE,EAAID,EACXC,EAAK,CAAE,EAAID,EACJC,EAERI,EAAIN,EAASO,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMP,EAAMQ,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMP,EAAMQ,CAAC,EAAE,GAExB,CACA,OAAAL,EAAK,CAAE,EAAIE,EACXF,EAAK,CAAE,EAAIG,EACJH,CACR,CAKAL,EAAO,QAAUC,IC1CjB,IAAIU,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "ndims", "min", "max", "s", "i", "require_assign", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "out", "ndims", "min", "max", "s", "i", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index 32b9185..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index b116911..757108e 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..46a79e6 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7cde065 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index d970542..cf3e431 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.2.1", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/utils-library-manifest": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer-array": "^0.2.1", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.2.1", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.2.1", - "@stdlib/ndarray-base-shape2strides": "^0.2.1", - "@stdlib/ndarray-base-strides2offset": "^0.2.1", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b00d034 --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From 303e4c753e0d2d12a9472c6fa8d9b4e6e4ebd793 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jun 2024 01:56:05 +0000 Subject: [PATCH 103/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index faa0c6f..d970542 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.3.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/utils-library-manifest": "^0.2.1" + "@stdlib/utils-library-manifest": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/assert-is-array": "^0.2.1", @@ -100,4 +101,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From b55f2a73712fb8001656904e33140bdf913fa5b6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jun 2024 03:21:23 +0000 Subject: [PATCH 104/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4917 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 757108e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 46a79e6..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7cde065..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b00d034..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5d3b34e6f7a0f843151e46ee8257a878dc33e90d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jun 2024 03:21:42 +0000 Subject: [PATCH 105/143] 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 | 248 - .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 | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 148 +- SECURITY.md | 5 - benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 336 -- 51 files changed, 4874 insertions(+), 5083 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c 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/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 3f381b9..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-06-01T01:28:22.560Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 94545a8..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/minmax-view-buffer-index) 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 ed2728d..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/minmax-view-buffer-index) 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 6eaad2f..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: '40 4 * * 4' - - # 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 f92a6c5..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 + + ```
@@ -174,106 +171,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -300,7 +198,7 @@ int main( void ) { ## 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]. 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 9d0db67..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index 753a2ff..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 `minmax_view_buffer_index`. -*/ -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -void print_version() { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -double tic() { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random double on the interval [0,1]. -* -* @return random double -*/ -double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -double benchmark() { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index d4659bb..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/minmax-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/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 31431c6..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import minmaxViewBufferIndex from '../docs/types/index'; -export = minmaxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index f4a239a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var s=function(i,v){return function(){return v||i((v={exports:{}}).exports,v),v.exports}};var c=s(function(V,t){ -function q(i,v,n){var e,x,m,a,r;for(e=i.length,x=n,m=n,r=0;r0?m+=a*(i[r]-1):a<0&&(x+=a*(i[r]-1))}return[x,m]}t.exports=q -});var l=s(function(y,d){ -function f(i,v,n,e){var x,m,a,r,u;for(x=i.length,m=n,a=n,u=0;u0?a+=r*(i[u]-1):r<0&&(m+=r*(i[u]-1))}return e[0]=m,e[1]=a,e}d.exports=f -});var w=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),g=c(),B=l();w(g,"assign",B);module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index d90186a..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAuBC,EAAOC,EAASC,EAAS,CACxD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAM,OACdI,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKP,EAAOO,CAAE,IAAM,EACnB,MAAO,CAAEL,EAAQA,CAAO,EAEzBI,EAAIL,EAASM,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMN,EAAMO,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,CAAC,EAAE,GAExB,CACA,MAAO,CAAEH,EAAKC,CAAI,CACnB,CAKAP,EAAO,QAAUC,ICzFjB,IAAAS,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA+EA,SAASC,EAAuBC,EAAOC,EAASC,EAAQC,EAAM,CAC7D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQJ,EAAM,OACdK,EAAMH,EACNI,EAAMJ,EACAM,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKR,EAAOQ,CAAE,IAAM,EACnB,OAAAL,EAAK,CAAE,EAAID,EACXC,EAAK,CAAE,EAAID,EACJC,EAERI,EAAIN,EAASO,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMP,EAAMQ,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMP,EAAMQ,CAAC,EAAE,GAExB,CACA,OAAAL,EAAK,CAAE,EAAIE,EACXF,EAAK,CAAE,EAAIG,EACJH,CACR,CAKAL,EAAO,QAAUC,IC1CjB,IAAIU,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "ndims", "min", "max", "s", "i", "require_assign", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "out", "ndims", "min", "max", "s", "i", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index 32b9185..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index b116911..757108e 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..46a79e6 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7cde065 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index d970542..cf3e431 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.2.1", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/utils-library-manifest": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer-array": "^0.2.1", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.2.1", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.2.1", - "@stdlib/ndarray-base-shape2strides": "^0.2.1", - "@stdlib/ndarray-base-strides2offset": "^0.2.1", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b00d034 --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From 47f942ffeb42e3fa93b21f884803db7d6ff656af Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jul 2024 01:53:30 +0000 Subject: [PATCH 106/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index faa0c6f..d970542 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.3.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/utils-library-manifest": "^0.2.1" + "@stdlib/utils-library-manifest": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/assert-is-array": "^0.2.1", @@ -100,4 +101,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 0d0d4041564024cc4fd07999a89b2f87c6cef9b7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jul 2024 03:22:17 +0000 Subject: [PATCH 107/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4917 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 757108e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 46a79e6..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7cde065..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b00d034..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 8b0ac8446c42a94d1de13070730ab008ed7b67a1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jul 2024 03:22:33 +0000 Subject: [PATCH 108/143] 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 | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 38 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 148 +- SECURITY.md | 5 - benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 336 -- 51 files changed, 4874 insertions(+), 5120 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c 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/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 b3dfad7..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-07-01T01:25:00.533Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 94545a8..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/minmax-view-buffer-index) 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 ed2728d..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/minmax-view-buffer-index) 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 6eaad2f..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: '40 4 * * 4' - - # 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 f92a6c5..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 + + ```
@@ -174,106 +171,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -300,7 +198,7 @@ int main( void ) { ## 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]. 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 9d0db67..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index 753a2ff..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 `minmax_view_buffer_index`. -*/ -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -void print_version() { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -double tic() { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random double on the interval [0,1]. -* -* @return random double -*/ -double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -double benchmark() { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index d4659bb..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/minmax-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/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 31431c6..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import minmaxViewBufferIndex from '../docs/types/index'; -export = minmaxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index f4a239a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var s=function(i,v){return function(){return v||i((v={exports:{}}).exports,v),v.exports}};var c=s(function(V,t){ -function q(i,v,n){var e,x,m,a,r;for(e=i.length,x=n,m=n,r=0;r0?m+=a*(i[r]-1):a<0&&(x+=a*(i[r]-1))}return[x,m]}t.exports=q -});var l=s(function(y,d){ -function f(i,v,n,e){var x,m,a,r,u;for(x=i.length,m=n,a=n,u=0;u0?a+=r*(i[u]-1):r<0&&(m+=r*(i[u]-1))}return e[0]=m,e[1]=a,e}d.exports=f -});var w=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),g=c(),B=l();w(g,"assign",B);module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index d90186a..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAuBC,EAAOC,EAASC,EAAS,CACxD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAM,OACdI,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKP,EAAOO,CAAE,IAAM,EACnB,MAAO,CAAEL,EAAQA,CAAO,EAEzBI,EAAIL,EAASM,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMN,EAAMO,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,CAAC,EAAE,GAExB,CACA,MAAO,CAAEH,EAAKC,CAAI,CACnB,CAKAP,EAAO,QAAUC,ICzFjB,IAAAS,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA+EA,SAASC,EAAuBC,EAAOC,EAASC,EAAQC,EAAM,CAC7D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQJ,EAAM,OACdK,EAAMH,EACNI,EAAMJ,EACAM,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKR,EAAOQ,CAAE,IAAM,EACnB,OAAAL,EAAK,CAAE,EAAID,EACXC,EAAK,CAAE,EAAID,EACJC,EAERI,EAAIN,EAASO,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMP,EAAMQ,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMP,EAAMQ,CAAC,EAAE,GAExB,CACA,OAAAL,EAAK,CAAE,EAAIE,EACXF,EAAK,CAAE,EAAIG,EACJH,CACR,CAKAL,EAAO,QAAUC,IC1CjB,IAAIU,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "ndims", "min", "max", "s", "i", "require_assign", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "out", "ndims", "min", "max", "s", "i", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index 32b9185..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index b116911..757108e 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..46a79e6 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7cde065 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index d970542..cf3e431 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.2.1", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/utils-library-manifest": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer-array": "^0.2.1", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.2.1", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.2.1", - "@stdlib/ndarray-base-shape2strides": "^0.2.1", - "@stdlib/ndarray-base-strides2offset": "^0.2.1", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b00d034 --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From bac0e9eba46ed0a142d82ea663a125dfe7cda409 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 02:13:16 +0000 Subject: [PATCH 109/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index a6ad547..effd6c3 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.3.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.1" + "@stdlib/utils-library-manifest": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-is-array": "^0.2.2", @@ -100,4 +101,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 9b347c5cca90fc853c7e1773a43e7f433833abea Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 02:45:26 +0000 Subject: [PATCH 110/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4917 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 757108e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 46a79e6..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7cde065..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b00d034..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 48e029011df07219babf5b50cd2602a5fc71f82e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 02:45:40 +0000 Subject: [PATCH 111/143] 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 | 207 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 148 +- SECURITY.md | 5 - benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 336 -- 50 files changed, 4874 insertions(+), 5288 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c 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/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 94545a8..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/minmax-view-buffer-index) 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 ed2728d..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/minmax-view-buffer-index) 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 6eaad2f..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: '40 4 * * 4' - - # 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 + + ```
@@ -174,106 +171,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -300,7 +198,7 @@ int main( void ) { ## 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]. 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 9d0db67..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index 753a2ff..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 `minmax_view_buffer_index`. -*/ -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -void print_version() { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -double tic() { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random double on the interval [0,1]. -* -* @return random double -*/ -double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -double benchmark() { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index d4659bb..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/minmax-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/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 31431c6..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import minmaxViewBufferIndex from '../docs/types/index'; -export = minmaxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index f4a239a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var s=function(i,v){return function(){return v||i((v={exports:{}}).exports,v),v.exports}};var c=s(function(V,t){ -function q(i,v,n){var e,x,m,a,r;for(e=i.length,x=n,m=n,r=0;r0?m+=a*(i[r]-1):a<0&&(x+=a*(i[r]-1))}return[x,m]}t.exports=q -});var l=s(function(y,d){ -function f(i,v,n,e){var x,m,a,r,u;for(x=i.length,m=n,a=n,u=0;u0?a+=r*(i[u]-1):r<0&&(m+=r*(i[u]-1))}return e[0]=m,e[1]=a,e}d.exports=f -});var w=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),g=c(),B=l();w(g,"assign",B);module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index d90186a..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAuBC,EAAOC,EAASC,EAAS,CACxD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAM,OACdI,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKP,EAAOO,CAAE,IAAM,EACnB,MAAO,CAAEL,EAAQA,CAAO,EAEzBI,EAAIL,EAASM,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMN,EAAMO,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,CAAC,EAAE,GAExB,CACA,MAAO,CAAEH,EAAKC,CAAI,CACnB,CAKAP,EAAO,QAAUC,ICzFjB,IAAAS,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA+EA,SAASC,EAAuBC,EAAOC,EAASC,EAAQC,EAAM,CAC7D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQJ,EAAM,OACdK,EAAMH,EACNI,EAAMJ,EACAM,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKR,EAAOQ,CAAE,IAAM,EACnB,OAAAL,EAAK,CAAE,EAAID,EACXC,EAAK,CAAE,EAAID,EACJC,EAERI,EAAIN,EAASO,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMP,EAAMQ,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMP,EAAMQ,CAAC,EAAE,GAExB,CACA,OAAAL,EAAK,CAAE,EAAIE,EACXF,EAAK,CAAE,EAAIG,EACJH,CACR,CAKAL,EAAO,QAAUC,IC1CjB,IAAIU,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "ndims", "min", "max", "s", "i", "require_assign", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "out", "ndims", "min", "max", "s", "i", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index 32b9185..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index b116911..757108e 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..46a79e6 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7cde065 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index effd6c3..31b0901 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.2.2", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer-array": "^0.2.1", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.2.1", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.2.1", - "@stdlib/ndarray-base-shape2strides": "^0.2.1", - "@stdlib/ndarray-base-strides2offset": "^0.2.1", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b00d034 --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From a7e0e577b8fa35a3e449b51eb361c344e0ca8904 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 03:04:10 +0000 Subject: [PATCH 112/143] Update README.md for ESM bundle v0.2.2 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e8d2e37..c2c8c2e 100644 --- a/README.md +++ b/README.md @@ -52,13 +52,13 @@ limitations under the License. ## Usage ```javascript -import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs'; +import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs'; ``` You can also import the following named exports from the package: ```javascript -import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs'; +import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs'; ``` #### minmaxViewBufferIndex( shape, strides, offset ) @@ -126,7 +126,7 @@ import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-d import shape2strides from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs'; import strides2offset from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs'; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-randu@esm/index.mjs'; -import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs'; +import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs'; var strides; var offset; From b7a7b28c62d5b39738bb3887b91ce953bb8d3986 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 03:04:11 +0000 Subject: [PATCH 113/143] Auto-generated commit --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c2c8c2e..ab9bf0e 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tags). For example, + ```javascript import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs'; ``` @@ -58,7 +63,7 @@ import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray You can also import the following named exports from the package: ```javascript -import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs'; +import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs'; ``` #### minmaxViewBufferIndex( shape, strides, offset ) @@ -126,7 +131,7 @@ import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-d import shape2strides from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs'; import strides2offset from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs'; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-randu@esm/index.mjs'; -import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs'; +import minmaxViewBufferIndex from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs'; var strides; var offset; From 7d424327a2657e98fd0184a9e14f99c9186c8951 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 01:57:05 +0000 Subject: [PATCH 114/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index fa1f263..10db609 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.3.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.2" + "@stdlib/utils-library-manifest": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-is-array": "^0.2.2", @@ -100,4 +101,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 830195bb5d74630a4cb4516058e7b0758df7a458 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 03:51:46 +0000 Subject: [PATCH 115/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4917 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 757108e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 46a79e6..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7cde065..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b00d034..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From bc5d6d8927b4364b65edaea13c9a1d85f4e49ead Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 03:52:02 +0000 Subject: [PATCH 116/143] 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 | 168 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 148 +- SECURITY.md | 5 - benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 138 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 336 -- 51 files changed, 4874 insertions(+), 5249 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c 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/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 af48822..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-01T01:29:25.830Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 94545a8..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/minmax-view-buffer-index) 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 ed2728d..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/minmax-view-buffer-index) 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 6eaad2f..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: '40 4 * * 4' - - # 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 + + ```
@@ -174,106 +171,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -300,7 +198,7 @@ int main( void ) { ## 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]. 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 9d0db67..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index dbbf895..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -static void print_version( void ) { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -static void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -static void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -static double tic( void ) { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random number on the interval [0,1). -* -* @return random number -*/ -static double rand_double( void ) { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -static double benchmark( void ) { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index d4659bb..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/minmax-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/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 31431c6..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import minmaxViewBufferIndex from '../docs/types/index'; -export = minmaxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index f4a239a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var s=function(i,v){return function(){return v||i((v={exports:{}}).exports,v),v.exports}};var c=s(function(V,t){ -function q(i,v,n){var e,x,m,a,r;for(e=i.length,x=n,m=n,r=0;r0?m+=a*(i[r]-1):a<0&&(x+=a*(i[r]-1))}return[x,m]}t.exports=q -});var l=s(function(y,d){ -function f(i,v,n,e){var x,m,a,r,u;for(x=i.length,m=n,a=n,u=0;u0?a+=r*(i[u]-1):r<0&&(m+=r*(i[u]-1))}return e[0]=m,e[1]=a,e}d.exports=f -});var w=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),g=c(),B=l();w(g,"assign",B);module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index d90186a..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAuBC,EAAOC,EAASC,EAAS,CACxD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAM,OACdI,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKP,EAAOO,CAAE,IAAM,EACnB,MAAO,CAAEL,EAAQA,CAAO,EAEzBI,EAAIL,EAASM,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMN,EAAMO,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,CAAC,EAAE,GAExB,CACA,MAAO,CAAEH,EAAKC,CAAI,CACnB,CAKAP,EAAO,QAAUC,ICzFjB,IAAAS,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA+EA,SAASC,EAAuBC,EAAOC,EAASC,EAAQC,EAAM,CAC7D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQJ,EAAM,OACdK,EAAMH,EACNI,EAAMJ,EACAM,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKR,EAAOQ,CAAE,IAAM,EACnB,OAAAL,EAAK,CAAE,EAAID,EACXC,EAAK,CAAE,EAAID,EACJC,EAERI,EAAIN,EAASO,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMP,EAAMQ,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMP,EAAMQ,CAAC,EAAE,GAExB,CACA,OAAAL,EAAK,CAAE,EAAIE,EACXF,EAAK,CAAE,EAAIG,EACJH,CACR,CAKAL,EAAO,QAAUC,IC1CjB,IAAIU,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "ndims", "min", "max", "s", "i", "require_assign", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "out", "ndims", "min", "max", "s", "i", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index 32b9185..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index b116911..757108e 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..46a79e6 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7cde065 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index 10db609..31b0901 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.2.2", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer-array": "^0.2.2", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b00d034 --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From 557bee9d3b8d63d35b4d65586d1d31546ec36545 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 16:37:28 +0000 Subject: [PATCH 117/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index fa1f263..10db609 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.3.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.2" + "@stdlib/utils-library-manifest": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-is-array": "^0.2.2", @@ -100,4 +101,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From b637747926a6b74c4aa3d21b4d38f0a7735af60b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 17:46:00 +0000 Subject: [PATCH 118/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4917 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 757108e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 46a79e6..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7cde065..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b00d034..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From f0834f687de4c106728b0d4b48a8fc19d5f1fd02 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 17:46:14 +0000 Subject: [PATCH 119/143] 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 | 241 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 148 +- SECURITY.md | 5 - benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 138 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 336 -- 51 files changed, 4874 insertions(+), 5322 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c 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/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 0464ddc..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-03T16:15:53.688Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 94545a8..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/minmax-view-buffer-index) 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 ed2728d..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/minmax-view-buffer-index) 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 6eaad2f..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: '40 4 * * 4' - - # 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 + + ```
@@ -174,106 +171,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -300,7 +198,7 @@ int main( void ) { ## 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]. 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 9d0db67..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index dbbf895..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -static void print_version( void ) { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -static void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -static void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -static double tic( void ) { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random number on the interval [0,1). -* -* @return random number -*/ -static double rand_double( void ) { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -static double benchmark( void ) { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index d4659bb..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/minmax-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/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 31431c6..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import minmaxViewBufferIndex from '../docs/types/index'; -export = minmaxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index f4a239a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var s=function(i,v){return function(){return v||i((v={exports:{}}).exports,v),v.exports}};var c=s(function(V,t){ -function q(i,v,n){var e,x,m,a,r;for(e=i.length,x=n,m=n,r=0;r0?m+=a*(i[r]-1):a<0&&(x+=a*(i[r]-1))}return[x,m]}t.exports=q -});var l=s(function(y,d){ -function f(i,v,n,e){var x,m,a,r,u;for(x=i.length,m=n,a=n,u=0;u0?a+=r*(i[u]-1):r<0&&(m+=r*(i[u]-1))}return e[0]=m,e[1]=a,e}d.exports=f -});var w=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),g=c(),B=l();w(g,"assign",B);module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index d90186a..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAuBC,EAAOC,EAASC,EAAS,CACxD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAM,OACdI,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKP,EAAOO,CAAE,IAAM,EACnB,MAAO,CAAEL,EAAQA,CAAO,EAEzBI,EAAIL,EAASM,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMN,EAAMO,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,CAAC,EAAE,GAExB,CACA,MAAO,CAAEH,EAAKC,CAAI,CACnB,CAKAP,EAAO,QAAUC,ICzFjB,IAAAS,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA+EA,SAASC,EAAuBC,EAAOC,EAASC,EAAQC,EAAM,CAC7D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQJ,EAAM,OACdK,EAAMH,EACNI,EAAMJ,EACAM,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKR,EAAOQ,CAAE,IAAM,EACnB,OAAAL,EAAK,CAAE,EAAID,EACXC,EAAK,CAAE,EAAID,EACJC,EAERI,EAAIN,EAASO,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMP,EAAMQ,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMP,EAAMQ,CAAC,EAAE,GAExB,CACA,OAAAL,EAAK,CAAE,EAAIE,EACXF,EAAK,CAAE,EAAIG,EACJH,CACR,CAKAL,EAAO,QAAUC,IC1CjB,IAAIU,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "ndims", "min", "max", "s", "i", "require_assign", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "out", "ndims", "min", "max", "s", "i", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index 32b9185..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index b116911..757108e 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..46a79e6 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7cde065 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index 10db609..31b0901 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.2.2", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer-array": "^0.2.2", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b00d034 --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From 055f3b1d3bc55f12c26f8665b4fb8556cb95d971 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 02:03:12 +0000 Subject: [PATCH 120/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index a9592e9..602b6ca 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.4.1", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.2" + "@stdlib/utils-library-manifest": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-is-array": "^0.2.2", @@ -100,4 +101,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From b4b4c2ed96b89afe51d9d4b3ea9d5633ebb531b1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 03:52:20 +0000 Subject: [PATCH 121/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4917 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 757108e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 46a79e6..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7cde065..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b00d034..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 021b3c77240ba1a6d648721dc34af3683c268253 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 03:52:42 +0000 Subject: [PATCH 122/143] 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 | 240 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 148 +- SECURITY.md | 5 - benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 138 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 336 -- 51 files changed, 4874 insertions(+), 5321 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c 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/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 7e7aad3..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-09-01T01:36:21.821Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 94545a8..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/minmax-view-buffer-index) 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 ed2728d..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/minmax-view-buffer-index) 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 6eaad2f..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: '40 4 * * 4' - - # 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 + + ```
@@ -174,106 +171,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -300,7 +198,7 @@ int main( void ) { ## 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]. 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 9d0db67..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index dbbf895..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -static void print_version( void ) { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -static void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -static void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -static double tic( void ) { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random number on the interval [0,1). -* -* @return random number -*/ -static double rand_double( void ) { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -static double benchmark( void ) { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index d4659bb..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/minmax-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/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 31431c6..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import minmaxViewBufferIndex from '../docs/types/index'; -export = minmaxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index f4a239a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var s=function(i,v){return function(){return v||i((v={exports:{}}).exports,v),v.exports}};var c=s(function(V,t){ -function q(i,v,n){var e,x,m,a,r;for(e=i.length,x=n,m=n,r=0;r0?m+=a*(i[r]-1):a<0&&(x+=a*(i[r]-1))}return[x,m]}t.exports=q -});var l=s(function(y,d){ -function f(i,v,n,e){var x,m,a,r,u;for(x=i.length,m=n,a=n,u=0;u0?a+=r*(i[u]-1):r<0&&(m+=r*(i[u]-1))}return e[0]=m,e[1]=a,e}d.exports=f -});var w=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),g=c(),B=l();w(g,"assign",B);module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index d90186a..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAuBC,EAAOC,EAASC,EAAS,CACxD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAM,OACdI,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKP,EAAOO,CAAE,IAAM,EACnB,MAAO,CAAEL,EAAQA,CAAO,EAEzBI,EAAIL,EAASM,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMN,EAAMO,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,CAAC,EAAE,GAExB,CACA,MAAO,CAAEH,EAAKC,CAAI,CACnB,CAKAP,EAAO,QAAUC,ICzFjB,IAAAS,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA+EA,SAASC,EAAuBC,EAAOC,EAASC,EAAQC,EAAM,CAC7D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQJ,EAAM,OACdK,EAAMH,EACNI,EAAMJ,EACAM,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKR,EAAOQ,CAAE,IAAM,EACnB,OAAAL,EAAK,CAAE,EAAID,EACXC,EAAK,CAAE,EAAID,EACJC,EAERI,EAAIN,EAASO,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMP,EAAMQ,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMP,EAAMQ,CAAC,EAAE,GAExB,CACA,OAAAL,EAAK,CAAE,EAAIE,EACXF,EAAK,CAAE,EAAIG,EACJH,CACR,CAKAL,EAAO,QAAUC,IC1CjB,IAAIU,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "ndims", "min", "max", "s", "i", "require_assign", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "out", "ndims", "min", "max", "s", "i", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index 32b9185..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index b116911..757108e 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..46a79e6 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7cde065 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index 602b6ca..31b0901 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.2.2", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.4.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer-array": "^0.2.2", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b00d034 --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From f72de10f53ccd27a32c430db021bf59379919c0d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 02:08:29 +0000 Subject: [PATCH 123/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index a9592e9..602b6ca 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.4.1", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.2" + "@stdlib/utils-library-manifest": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-is-array": "^0.2.2", @@ -100,4 +101,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From c98de664b5a223e2e861c646d5a83500a786ee9c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 03:39:54 +0000 Subject: [PATCH 124/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4917 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 757108e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 46a79e6..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7cde065..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b00d034..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From f27fde89e4a7e6edbd0ee99100da343e36867e79 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 03:40:15 +0000 Subject: [PATCH 125/143] 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 | 240 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 148 +- SECURITY.md | 5 - benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 138 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 336 -- 51 files changed, 4874 insertions(+), 5321 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c 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/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 ac485de..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-10-01T01:42:48.256Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 94545a8..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/minmax-view-buffer-index) 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 ed2728d..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/minmax-view-buffer-index) 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 6eaad2f..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: '40 4 * * 4' - - # 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 + + ```
@@ -174,106 +171,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -300,7 +198,7 @@ int main( void ) { ## 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]. 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 9d0db67..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index dbbf895..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -static void print_version( void ) { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -static void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -static void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -static double tic( void ) { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random number on the interval [0,1). -* -* @return random number -*/ -static double rand_double( void ) { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -static double benchmark( void ) { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index d4659bb..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/minmax-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/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 31431c6..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import minmaxViewBufferIndex from '../docs/types/index'; -export = minmaxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index f4a239a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var s=function(i,v){return function(){return v||i((v={exports:{}}).exports,v),v.exports}};var c=s(function(V,t){ -function q(i,v,n){var e,x,m,a,r;for(e=i.length,x=n,m=n,r=0;r0?m+=a*(i[r]-1):a<0&&(x+=a*(i[r]-1))}return[x,m]}t.exports=q -});var l=s(function(y,d){ -function f(i,v,n,e){var x,m,a,r,u;for(x=i.length,m=n,a=n,u=0;u0?a+=r*(i[u]-1):r<0&&(m+=r*(i[u]-1))}return e[0]=m,e[1]=a,e}d.exports=f -});var w=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),g=c(),B=l();w(g,"assign",B);module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index d90186a..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAuBC,EAAOC,EAASC,EAAS,CACxD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAM,OACdI,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKP,EAAOO,CAAE,IAAM,EACnB,MAAO,CAAEL,EAAQA,CAAO,EAEzBI,EAAIL,EAASM,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMN,EAAMO,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,CAAC,EAAE,GAExB,CACA,MAAO,CAAEH,EAAKC,CAAI,CACnB,CAKAP,EAAO,QAAUC,ICzFjB,IAAAS,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA+EA,SAASC,EAAuBC,EAAOC,EAASC,EAAQC,EAAM,CAC7D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQJ,EAAM,OACdK,EAAMH,EACNI,EAAMJ,EACAM,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKR,EAAOQ,CAAE,IAAM,EACnB,OAAAL,EAAK,CAAE,EAAID,EACXC,EAAK,CAAE,EAAID,EACJC,EAERI,EAAIN,EAASO,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMP,EAAMQ,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMP,EAAMQ,CAAC,EAAE,GAExB,CACA,OAAAL,EAAK,CAAE,EAAIE,EACXF,EAAK,CAAE,EAAIG,EACJH,CACR,CAKAL,EAAO,QAAUC,IC1CjB,IAAIU,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "ndims", "min", "max", "s", "i", "require_assign", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "out", "ndims", "min", "max", "s", "i", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index 32b9185..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index b116911..757108e 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..46a79e6 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7cde065 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index 602b6ca..31b0901 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.2.2", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.4.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer-array": "^0.2.2", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b00d034 --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From 43548602843fe8bcff8fa6a00366031a7ad57bd4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 02:05:33 +0000 Subject: [PATCH 126/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index a9592e9..602b6ca 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.4.1", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.2" + "@stdlib/utils-library-manifest": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-is-array": "^0.2.2", @@ -100,4 +101,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 8031975ca1a788ffac9ffa89766e7848a6067348 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 03:36:04 +0000 Subject: [PATCH 127/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4917 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 757108e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 46a79e6..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7cde065..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b00d034..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From f1390ffef5905d2835222d6aa1de2f3f6c26166a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 03:36:17 +0000 Subject: [PATCH 128/143] 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 | 240 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 148 +- SECURITY.md | 5 - benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 138 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 336 -- 51 files changed, 4874 insertions(+), 5321 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c 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/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 1c01639..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-11-01T01:40:00.303Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 94545a8..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/minmax-view-buffer-index) 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 ed2728d..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/minmax-view-buffer-index) 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 6eaad2f..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: '40 4 * * 4' - - # 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 + + ```
@@ -174,106 +171,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -300,7 +198,7 @@ int main( void ) { ## 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]. 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 9d0db67..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index dbbf895..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -static void print_version( void ) { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -static void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -static void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -static double tic( void ) { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random number on the interval [0,1). -* -* @return random number -*/ -static double rand_double( void ) { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -static double benchmark( void ) { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index d4659bb..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/minmax-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/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 31431c6..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import minmaxViewBufferIndex from '../docs/types/index'; -export = minmaxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index f4a239a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var s=function(i,v){return function(){return v||i((v={exports:{}}).exports,v),v.exports}};var c=s(function(V,t){ -function q(i,v,n){var e,x,m,a,r;for(e=i.length,x=n,m=n,r=0;r0?m+=a*(i[r]-1):a<0&&(x+=a*(i[r]-1))}return[x,m]}t.exports=q -});var l=s(function(y,d){ -function f(i,v,n,e){var x,m,a,r,u;for(x=i.length,m=n,a=n,u=0;u0?a+=r*(i[u]-1):r<0&&(m+=r*(i[u]-1))}return e[0]=m,e[1]=a,e}d.exports=f -});var w=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),g=c(),B=l();w(g,"assign",B);module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index d90186a..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAuBC,EAAOC,EAASC,EAAS,CACxD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAM,OACdI,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKP,EAAOO,CAAE,IAAM,EACnB,MAAO,CAAEL,EAAQA,CAAO,EAEzBI,EAAIL,EAASM,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMN,EAAMO,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,CAAC,EAAE,GAExB,CACA,MAAO,CAAEH,EAAKC,CAAI,CACnB,CAKAP,EAAO,QAAUC,ICzFjB,IAAAS,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA+EA,SAASC,EAAuBC,EAAOC,EAASC,EAAQC,EAAM,CAC7D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQJ,EAAM,OACdK,EAAMH,EACNI,EAAMJ,EACAM,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKR,EAAOQ,CAAE,IAAM,EACnB,OAAAL,EAAK,CAAE,EAAID,EACXC,EAAK,CAAE,EAAID,EACJC,EAERI,EAAIN,EAASO,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMP,EAAMQ,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMP,EAAMQ,CAAC,EAAE,GAExB,CACA,OAAAL,EAAK,CAAE,EAAIE,EACXF,EAAK,CAAE,EAAIG,EACJH,CACR,CAKAL,EAAO,QAAUC,IC1CjB,IAAIU,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "ndims", "min", "max", "s", "i", "require_assign", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "out", "ndims", "min", "max", "s", "i", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index 32b9185..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index b116911..757108e 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..46a79e6 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7cde065 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index 602b6ca..31b0901 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.2.2", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.4.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer-array": "^0.2.2", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b00d034 --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From 21b9261399fa927a64fb7909d9e10e59fe42c3f4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 02:11:54 +0000 Subject: [PATCH 129/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 234818e..f6c62bf 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.2" + "@stdlib/utils-library-manifest": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-is-array": "^0.2.2", @@ -100,4 +101,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From f9b26e2cc2cc399beaa03cab699ce3b94f7edaf1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 03:40:31 +0000 Subject: [PATCH 130/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4917 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 757108e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 46a79e6..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7cde065..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b00d034..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5f5c59f0257c877506be1388eff8fb60299d5128 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 03:40:47 +0000 Subject: [PATCH 131/143] 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 | 240 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 148 +- SECURITY.md | 5 - benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 138 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 336 -- 52 files changed, 4874 insertions(+), 5426 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c 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/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 7d721b5..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-01T01:46:30.671Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 94545a8..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/minmax-view-buffer-index) 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 ed2728d..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/minmax-view-buffer-index) 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 6eaad2f..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: '40 4 * * 4' - - # 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 + + ```
@@ -174,106 +171,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -300,7 +198,7 @@ int main( void ) { ## 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]. 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 9d0db67..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index dbbf895..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -static void print_version( void ) { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -static void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -static void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -static double tic( void ) { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random number on the interval [0,1). -* -* @return random number -*/ -static double rand_double( void ) { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -static double benchmark( void ) { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index d4659bb..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/minmax-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/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 31431c6..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import minmaxViewBufferIndex from '../docs/types/index'; -export = minmaxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index f4a239a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var s=function(i,v){return function(){return v||i((v={exports:{}}).exports,v),v.exports}};var c=s(function(V,t){ -function q(i,v,n){var e,x,m,a,r;for(e=i.length,x=n,m=n,r=0;r0?m+=a*(i[r]-1):a<0&&(x+=a*(i[r]-1))}return[x,m]}t.exports=q -});var l=s(function(y,d){ -function f(i,v,n,e){var x,m,a,r,u;for(x=i.length,m=n,a=n,u=0;u0?a+=r*(i[u]-1):r<0&&(m+=r*(i[u]-1))}return e[0]=m,e[1]=a,e}d.exports=f -});var w=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),g=c(),B=l();w(g,"assign",B);module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index d90186a..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAuBC,EAAOC,EAASC,EAAS,CACxD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAM,OACdI,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKP,EAAOO,CAAE,IAAM,EACnB,MAAO,CAAEL,EAAQA,CAAO,EAEzBI,EAAIL,EAASM,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMN,EAAMO,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,CAAC,EAAE,GAExB,CACA,MAAO,CAAEH,EAAKC,CAAI,CACnB,CAKAP,EAAO,QAAUC,ICzFjB,IAAAS,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA+EA,SAASC,EAAuBC,EAAOC,EAASC,EAAQC,EAAM,CAC7D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQJ,EAAM,OACdK,EAAMH,EACNI,EAAMJ,EACAM,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKR,EAAOQ,CAAE,IAAM,EACnB,OAAAL,EAAK,CAAE,EAAID,EACXC,EAAK,CAAE,EAAID,EACJC,EAERI,EAAIN,EAASO,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMP,EAAMQ,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMP,EAAMQ,CAAC,EAAE,GAExB,CACA,OAAAL,EAAK,CAAE,EAAIE,EACXF,EAAK,CAAE,EAAIG,EACJH,CACR,CAKAL,EAAO,QAAUC,IC1CjB,IAAIU,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "ndims", "min", "max", "s", "i", "require_assign", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "out", "ndims", "min", "max", "s", "i", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index 32b9185..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index b116911..757108e 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..46a79e6 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7cde065 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index f6c62bf..31b0901 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.2.2", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer-array": "^0.2.2", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b00d034 --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From 10f8ccf44b334b92a04da6a3b889e2c17869ddf0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Dec 2024 01:51:57 +0000 Subject: [PATCH 132/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 234818e..f6c62bf 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.2" + "@stdlib/utils-library-manifest": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-is-array": "^0.2.2", @@ -100,4 +101,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 0b98d585326934e043616c0fb2407e2e44be567a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Dec 2024 02:08:00 +0000 Subject: [PATCH 133/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4917 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 757108e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 46a79e6..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7cde065..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b00d034..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 15f3f53136398fbf40335693882018b508b18ed9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Dec 2024 02:08:21 +0000 Subject: [PATCH 134/143] 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 | 240 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 148 +- SECURITY.md | 5 - benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 138 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 336 -- 52 files changed, 4874 insertions(+), 5426 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c 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/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 d128cbf..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-23T01:46:46.518Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 94545a8..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/minmax-view-buffer-index) 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 ed2728d..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/minmax-view-buffer-index) 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 6eaad2f..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: '40 4 * * 4' - - # 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 + + ```
@@ -174,106 +171,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -300,7 +198,7 @@ int main( void ) { ## 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]. 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 9d0db67..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index dbbf895..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -static void print_version( void ) { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -static void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -static void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -static double tic( void ) { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random number on the interval [0,1). -* -* @return random number -*/ -static double rand_double( void ) { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -static double benchmark( void ) { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index d4659bb..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/minmax-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/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 31431c6..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import minmaxViewBufferIndex from '../docs/types/index'; -export = minmaxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index f4a239a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var s=function(i,v){return function(){return v||i((v={exports:{}}).exports,v),v.exports}};var c=s(function(V,t){ -function q(i,v,n){var e,x,m,a,r;for(e=i.length,x=n,m=n,r=0;r0?m+=a*(i[r]-1):a<0&&(x+=a*(i[r]-1))}return[x,m]}t.exports=q -});var l=s(function(y,d){ -function f(i,v,n,e){var x,m,a,r,u;for(x=i.length,m=n,a=n,u=0;u0?a+=r*(i[u]-1):r<0&&(m+=r*(i[u]-1))}return e[0]=m,e[1]=a,e}d.exports=f -});var w=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),g=c(),B=l();w(g,"assign",B);module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index d90186a..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAuBC,EAAOC,EAASC,EAAS,CACxD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAM,OACdI,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKP,EAAOO,CAAE,IAAM,EACnB,MAAO,CAAEL,EAAQA,CAAO,EAEzBI,EAAIL,EAASM,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMN,EAAMO,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,CAAC,EAAE,GAExB,CACA,MAAO,CAAEH,EAAKC,CAAI,CACnB,CAKAP,EAAO,QAAUC,ICzFjB,IAAAS,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA+EA,SAASC,EAAuBC,EAAOC,EAASC,EAAQC,EAAM,CAC7D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQJ,EAAM,OACdK,EAAMH,EACNI,EAAMJ,EACAM,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKR,EAAOQ,CAAE,IAAM,EACnB,OAAAL,EAAK,CAAE,EAAID,EACXC,EAAK,CAAE,EAAID,EACJC,EAERI,EAAIN,EAASO,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMP,EAAMQ,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMP,EAAMQ,CAAC,EAAE,GAExB,CACA,OAAAL,EAAK,CAAE,EAAIE,EACXF,EAAK,CAAE,EAAIG,EACJH,CACR,CAKAL,EAAO,QAAUC,IC1CjB,IAAIU,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "ndims", "min", "max", "s", "i", "require_assign", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "out", "ndims", "min", "max", "s", "i", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index 32b9185..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index b116911..757108e 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..46a79e6 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7cde065 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index f6c62bf..31b0901 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.2.2", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer-array": "^0.2.2", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b00d034 --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From 99107e16d0e1934bbf642e0c9b81f6df9f4491c6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 13 Jan 2025 02:44:18 +0000 Subject: [PATCH 135/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 234818e..f6c62bf 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.2" + "@stdlib/utils-library-manifest": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-is-array": "^0.2.2", @@ -100,4 +101,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 038b9fdeeef68450153dc9f4a16e11e7cdfc74a9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 13 Jan 2025 03:21:17 +0000 Subject: [PATCH 136/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4917 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 757108e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 46a79e6..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7cde065..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b00d034..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 98eba854aa77531281368496bb79b73f427c00f1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 13 Jan 2025 03:21:32 +0000 Subject: [PATCH 137/143] 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 | 240 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 148 +- SECURITY.md | 5 - benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 138 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 336 -- 52 files changed, 4874 insertions(+), 5426 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c 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/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 080aad5..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-01-13T02:26:50.025Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 94545a8..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/minmax-view-buffer-index) 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 ed2728d..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/minmax-view-buffer-index) 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 6eaad2f..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: '40 4 * * 4' - - # 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 + + ```
@@ -174,106 +171,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -300,7 +198,7 @@ int main( void ) { ## 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]. 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 9d0db67..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index dbbf895..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -static void print_version( void ) { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -static void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -static void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -static double tic( void ) { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random number on the interval [0,1). -* -* @return random number -*/ -static double rand_double( void ) { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -static double benchmark( void ) { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index d4659bb..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/minmax-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/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 31431c6..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import minmaxViewBufferIndex from '../docs/types/index'; -export = minmaxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index f4a239a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var s=function(i,v){return function(){return v||i((v={exports:{}}).exports,v),v.exports}};var c=s(function(V,t){ -function q(i,v,n){var e,x,m,a,r;for(e=i.length,x=n,m=n,r=0;r0?m+=a*(i[r]-1):a<0&&(x+=a*(i[r]-1))}return[x,m]}t.exports=q -});var l=s(function(y,d){ -function f(i,v,n,e){var x,m,a,r,u;for(x=i.length,m=n,a=n,u=0;u0?a+=r*(i[u]-1):r<0&&(m+=r*(i[u]-1))}return e[0]=m,e[1]=a,e}d.exports=f -});var w=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),g=c(),B=l();w(g,"assign",B);module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index d90186a..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAuBC,EAAOC,EAASC,EAAS,CACxD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAM,OACdI,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKP,EAAOO,CAAE,IAAM,EACnB,MAAO,CAAEL,EAAQA,CAAO,EAEzBI,EAAIL,EAASM,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMN,EAAMO,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,CAAC,EAAE,GAExB,CACA,MAAO,CAAEH,EAAKC,CAAI,CACnB,CAKAP,EAAO,QAAUC,ICzFjB,IAAAS,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA+EA,SAASC,EAAuBC,EAAOC,EAASC,EAAQC,EAAM,CAC7D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQJ,EAAM,OACdK,EAAMH,EACNI,EAAMJ,EACAM,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKR,EAAOQ,CAAE,IAAM,EACnB,OAAAL,EAAK,CAAE,EAAID,EACXC,EAAK,CAAE,EAAID,EACJC,EAERI,EAAIN,EAASO,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMP,EAAMQ,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMP,EAAMQ,CAAC,EAAE,GAExB,CACA,OAAAL,EAAK,CAAE,EAAIE,EACXF,EAAK,CAAE,EAAIG,EACJH,CACR,CAKAL,EAAO,QAAUC,IC1CjB,IAAIU,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "ndims", "min", "max", "s", "i", "require_assign", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "out", "ndims", "min", "max", "s", "i", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index 32b9185..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index b116911..757108e 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f9c1421 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7cde065 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 890a937..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index f6c62bf..31b0901 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.2.2", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer-array": "^0.2.2", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b00d034 --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From 7c06fd82f49d67a8f80c6906cb14f208b00ee1f9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 18 Mar 2025 06:35:38 +0000 Subject: [PATCH 138/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 234818e..f6c62bf 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.2" + "@stdlib/utils-library-manifest": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-is-array": "^0.2.2", @@ -100,4 +101,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From ef033a38fde584e20c9bc77b93deb8d17f704035 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 18 Mar 2025 06:36:23 +0000 Subject: [PATCH 139/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4917 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 757108e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f9c1421..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7cde065..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b00d034..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c11871594e2ac2456fd0fdce1708e474c24455f9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 18 Mar 2025 06:36:55 +0000 Subject: [PATCH 140/143] 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 | 242 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 148 +- SECURITY.md | 5 - benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 138 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 336 -- 51 files changed, 4874 insertions(+), 5430 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c 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/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 d71813c..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/minmax-view-buffer-index) 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 ed2728d..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/minmax-view-buffer-index) 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 6eaad2f..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: '40 4 * * 4' - - # 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 + + ```
@@ -174,106 +171,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -300,7 +198,7 @@ int main( void ) { ## 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]. 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 9d0db67..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index dbbf895..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -static void print_version( void ) { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -static void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -static void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -static double tic( void ) { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random number on the interval [0,1). -* -* @return random number -*/ -static double rand_double( void ) { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -static double benchmark( void ) { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index d4659bb..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/minmax-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/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 31431c6..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import minmaxViewBufferIndex from '../docs/types/index'; -export = minmaxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index f4a239a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var s=function(i,v){return function(){return v||i((v={exports:{}}).exports,v),v.exports}};var c=s(function(V,t){ -function q(i,v,n){var e,x,m,a,r;for(e=i.length,x=n,m=n,r=0;r0?m+=a*(i[r]-1):a<0&&(x+=a*(i[r]-1))}return[x,m]}t.exports=q -});var l=s(function(y,d){ -function f(i,v,n,e){var x,m,a,r,u;for(x=i.length,m=n,a=n,u=0;u0?a+=r*(i[u]-1):r<0&&(m+=r*(i[u]-1))}return e[0]=m,e[1]=a,e}d.exports=f -});var w=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),g=c(),B=l();w(g,"assign",B);module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index d90186a..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAuBC,EAAOC,EAASC,EAAS,CACxD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAM,OACdI,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKP,EAAOO,CAAE,IAAM,EACnB,MAAO,CAAEL,EAAQA,CAAO,EAEzBI,EAAIL,EAASM,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMN,EAAMO,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,CAAC,EAAE,GAExB,CACA,MAAO,CAAEH,EAAKC,CAAI,CACnB,CAKAP,EAAO,QAAUC,ICzFjB,IAAAS,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA+EA,SAASC,EAAuBC,EAAOC,EAASC,EAAQC,EAAM,CAC7D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQJ,EAAM,OACdK,EAAMH,EACNI,EAAMJ,EACAM,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKR,EAAOQ,CAAE,IAAM,EACnB,OAAAL,EAAK,CAAE,EAAID,EACXC,EAAK,CAAE,EAAID,EACJC,EAERI,EAAIN,EAASO,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMP,EAAMQ,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMP,EAAMQ,CAAC,EAAE,GAExB,CACA,OAAAL,EAAK,CAAE,EAAIE,EACXF,EAAK,CAAE,EAAIG,EACJH,CACR,CAKAL,EAAO,QAAUC,IC1CjB,IAAIU,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "ndims", "min", "max", "s", "i", "require_assign", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "out", "ndims", "min", "max", "s", "i", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index 32b9185..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index abb89d6..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index b116911..757108e 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f9c1421 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7cde065 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 04e61e3..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index f6c62bf..31b0901 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.2.2", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer-array": "^0.2.2", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ed95676..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b00d034 --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -}); From 58f5fb0a9a6035cceb9253a67a84f1e61923db9c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 12 Jul 2025 10:24:01 +0000 Subject: [PATCH 141/143] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 234818e..f6c62bf 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "dependencies": { "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.2" + "@stdlib/utils-library-manifest": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-is-array": "^0.2.2", @@ -100,4 +101,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From a7e678b04ebc78c6f6447016ee4c1020a79975ef Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 12 Jul 2025 10:24:19 +0000 Subject: [PATCH 142/143] Remove files --- index.d.ts | 70 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4917 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 757108e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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'; - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -declare function minmaxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): Array; - - -// EXPORTS // - -export = minmaxViewBufferIndex; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f9c1421..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7cde065..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b00d034..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 90bf5c6f9af73a1b096f8a891de340263797157d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 12 Jul 2025 10:25:16 +0000 Subject: [PATCH 143/143] 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 | 256 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 148 +- SECURITY.md | 5 - benchmark/benchmark.js | 158 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 138 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 78 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 34 - examples/index.js | 57 - .../ndarray/base/minmax_view_buffer_index.h | 40 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 111 - lib/index.js | 81 - lib/main.js | 90 - manifest.json | 38 - package.json | 67 +- src/main.c | 75 - stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 336 -- 51 files changed, 4874 insertions(+), 5444 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/c/Makefile delete mode 100644 benchmark/c/benchmark.c 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/c/Makefile delete mode 100644 examples/c/example.c delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/minmax_view_buffer_index.h rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 manifest.json delete mode 100644 src/main.c 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 d71813c..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/minmax-view-buffer-index) 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 ed2728d..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/minmax-view-buffer-index) 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 6eaad2f..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: '40 4 * * 4' - - # 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 + + ```
@@ -174,106 +171,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -``` - -#### stdlib_ndarray_minmax_view_buffer_index( ndims, \*shape, \*strides, offset, \*out ) - -Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. - -```c -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; -int64_t out[ 2 ]; - -stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - -int64_t min = out[ 0 ]; -// returns 0 - -int64_t max = out[ 1 ]; -// returns 99 -``` - -The function accepts the following arguments: - -- **ndims**: `[in] int64_t` number of dimensions. -- **shape**: `[in] int64_t*` array shape (dimensions). -- **strides**: `[in] int64_t*` array strides (in bytes). -- **offset**: `[in] int64_t` index offset. -- **out**: `[out] int64_t*` two-element output array. - -```c -int8_t stdlib_ndarray_minmax_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int64_t *out ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} -``` - -
- - - -
- @@ -300,7 +198,7 @@ int main( void ) { ## 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]. 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 9d0db67..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' ); -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -var pkg = require( './../package.json' ).name; -var minmaxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = minmaxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::memory_reuse:assign', function benchmark( b ) { - var strides; - var shape; - var out; - var mm; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - mm = minmaxViewBufferIndex( shape, strides, 1000, out ); - if ( mm.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( mm ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = [ 0, 0 ]; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::separately,memory_reuse', function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - out = [ 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out[ 0 ] = minViewBufferIndex( shape, strides, 1000 ); - out[ 1 ] = maxViewBufferIndex( shape, strides, 1000 ); - if ( out.length !== 2 ) { - b.fail( 'should return an array having two elements' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array containing nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/c/Makefile b/benchmark/c/Makefile deleted file mode 100644 index c12ea19..0000000 --- a/benchmark/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - - -# RULES # - -#/ -# Compiles C source files. -# -# @param {string} SOURCE_FILES - list of C source files -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [C_COMPILER] - C compiler -# @param {string} [CFLAGS] - C compiler flags -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} SOURCE_FILES - list of C source files -# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) -# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) -# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/benchmark/c/benchmark.c b/benchmark/c/benchmark.c deleted file mode 100644 index dbbf895..0000000 --- a/benchmark/c/benchmark.c +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "minmax-view-buffer-index" -#define ITERATIONS 1000000 -#define REPEATS 3 - -/** -* Prints the TAP version. -*/ -static void print_version( void ) { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @param total total number of tests -* @param passing total number of passing tests -*/ -static void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); -} - -/** -* Prints benchmarks results. -* -* @param elapsed elapsed time in seconds -*/ -static void print_results( double elapsed ) { - double rate = (double)ITERATIONS / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", ITERATIONS ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -static double tic( void ) { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random number on the interval [0,1). -* -* @return random number -*/ -static double rand_double( void ) { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @return elapsed time in seconds -*/ -static double benchmark( void ) { - double elapsed; - double t; - int i; - - int64_t out[ 2 ]; - int64_t shape[] = { 10, 10, 10 }; - int64_t strides[] = { 100, 10, 1 }; - int64_t offset = 1000; - int64_t ndims = 3; - - t = tic(); - for ( i = 0; i < ITERATIONS; i++ ) { - strides[ 0 ] *= ( rand_double() < 0.5 ) ? 1 : -1; - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( out[ 0 ] > 1e10 ) { - printf( "unexpected result\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int i; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - for ( i = 0; i < REPEATS; i++ ) { - printf( "# c::native::%s\n", NAME ); - elapsed = benchmark(); - print_results( elapsed ); - printf( "ok %d benchmark finished\n", i+1 ); - } - print_summary( REPEATS, REPEATS ); -} diff --git a/branches.md b/branches.md deleted file mode 100644 index d4659bb..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/minmax-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/minmax-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-minmax-view-buffer-index/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 31431c6..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import minmaxViewBufferIndex from '../docs/types/index'; -export = minmaxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index f4a239a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var s=function(i,v){return function(){return v||i((v={exports:{}}).exports,v),v.exports}};var c=s(function(V,t){ -function q(i,v,n){var e,x,m,a,r;for(e=i.length,x=n,m=n,r=0;r0?m+=a*(i[r]-1):a<0&&(x+=a*(i[r]-1))}return[x,m]}t.exports=q -});var l=s(function(y,d){ -function f(i,v,n,e){var x,m,a,r,u;for(x=i.length,m=n,a=n,u=0;u0?a+=r*(i[u]-1):r<0&&(m+=r*(i[u]-1))}return e[0]=m,e[1]=a,e}d.exports=f -});var w=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),g=c(),B=l();w(g,"assign",B);module.exports=g; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index d90186a..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = minmaxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAuBC,EAAOC,EAASC,EAAS,CACxD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAM,OACdI,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKP,EAAOO,CAAE,IAAM,EACnB,MAAO,CAAEL,EAAQA,CAAO,EAEzBI,EAAIL,EAASM,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMN,EAAMO,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,CAAC,EAAE,GAExB,CACA,MAAO,CAAEH,EAAKC,CAAI,CACnB,CAKAP,EAAO,QAAUC,ICzFjB,IAAAS,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA+EA,SAASC,EAAuBC,EAAOC,EAASC,EAAQC,EAAM,CAC7D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQJ,EAAM,OACdK,EAAMH,EACNI,EAAMJ,EACAM,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAKR,EAAOQ,CAAE,IAAM,EACnB,OAAAL,EAAK,CAAE,EAAID,EACXC,EAAK,CAAE,EAAID,EACJC,EAERI,EAAIN,EAASO,CAAE,EACVD,EAAI,EACRD,GAAOC,GAAMP,EAAMQ,CAAC,EAAE,GACXD,EAAI,IACfF,GAAOE,GAAMP,EAAMQ,CAAC,EAAE,GAExB,CACA,OAAAL,EAAK,CAAE,EAAIE,EACXF,EAAK,CAAE,EAAIG,EACJH,CACR,CAKAL,EAAO,QAAUC,IC1CjB,IAAIU,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "ndims", "min", "max", "s", "i", "require_assign", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "shape", "strides", "offset", "out", "ndims", "min", "max", "s", "i", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bd04e88..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,78 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - Returns - ------- - out: Array - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - [ 0, 59 ] - - -{{alias}}.assign( shape, strides, offset, out ) - Computes the minimum and maximum linear indices in an underlying data buffer - which are accessible to an array view and assigns results to a provided - output array. - - Parameters - ---------- - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - out: Array|TypedArray|Object - Output array. - - Returns - ------- - out: Array|TypedArray|Object - Minimum and maximum linear indices in an underlying data buffer which - are accessible to an array view. - - Examples - -------- - > var d = [ 2, 3, 10 ]; - > var s = [ 30, -10, 1 ]; - > var o = 20; - > var arr = [ 0, 0 ]; - > var out = {{alias}}.assign( d, s, o, arr ) - [ 0, 59 ] - > var bool = ( out === arr ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cea4722..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import minmaxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ], 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object containing numbers... -{ - const strides = [ 10, 1 ]; - const offset = 10; - minmaxViewBufferIndex( true, strides, offset ); // $ExpectError - minmaxViewBufferIndex( false, strides, offset ); // $ExpectError - minmaxViewBufferIndex( null, strides, offset ); // $ExpectError - minmaxViewBufferIndex( undefined, strides, offset ); // $ExpectError - minmaxViewBufferIndex( '5', strides, offset ); // $ExpectError - minmaxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - minmaxViewBufferIndex( {}, strides, offset ); // $ExpectError - minmaxViewBufferIndex( ( x: number ): number => x, strides, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const shape = [ 10, 10 ]; - const offset = 10; - minmaxViewBufferIndex( shape, true, offset ); // $ExpectError - minmaxViewBufferIndex( shape, false, offset ); // $ExpectError - minmaxViewBufferIndex( shape, null, offset ); // $ExpectError - minmaxViewBufferIndex( shape, undefined, offset ); // $ExpectError - minmaxViewBufferIndex( shape, '5', offset ); // $ExpectError - minmaxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - minmaxViewBufferIndex( shape, {}, offset ); // $ExpectError - minmaxViewBufferIndex( shape, ( x: number ): number => x, offset ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const shape = [ 10, 10 ]; - const strides = [ 10, 1 ]; - minmaxViewBufferIndex( shape, strides, true ); // $ExpectError - minmaxViewBufferIndex( shape, strides, false ); // $ExpectError - minmaxViewBufferIndex( shape, strides, null ); // $ExpectError - minmaxViewBufferIndex( shape, strides, undefined ); // $ExpectError - minmaxViewBufferIndex( shape, strides, '5' ); // $ExpectError - minmaxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - minmaxViewBufferIndex( shape, strides, {} ); // $ExpectError - minmaxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - minmaxViewBufferIndex(); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - minmaxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index ff5293d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2020 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# VARIABLES # - -ifndef VERBOSE - QUIET := @ -else - QUIET := -endif - -# Determine the OS ([1][1], [2][2]). -# -# [1]: https://en.wikipedia.org/wiki/Uname#Examples -# [2]: http://stackoverflow.com/a/27776822/2225624 -OS ?= $(shell uname) -ifneq (, $(findstring MINGW,$(OS))) - OS := WINNT -else -ifneq (, $(findstring MSYS,$(OS))) - OS := WINNT -else -ifneq (, $(findstring CYGWIN,$(OS))) - OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif -endif -endif -endif - -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := example.out - - -# RULES # - -#/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled examples. -# -# @example -# make run -#/ -run: $(c_targets) - $(QUIET) ./$< - -.PHONY: run - -#/ -# Removes generated files. -# -# @example -# make clean -#/ -clean: - $(QUIET) -rm -f *.o *.out - -.PHONY: clean diff --git a/examples/c/example.c b/examples/c/example.c deleted file mode 100644 index 32b9185..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include -#include - -int main( void ) { - int64_t ndims = 2; - int64_t shape[] = { 10, 10 }; - int64_t strides[] = { 10, 1 }; - int64_t offset = 0; - int64_t out[ 2 ]; - - stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); - - printf( "min: %"PRId64"\n", out[ 0 ] ); - printf( "max: %"PRId64"\n", out[ 1 ] ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 01a47fb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var randu = require( '@stdlib/random-base-randu' ); -var minmaxViewBufferIndex = require( './../lib' ); - -var strides; -var offset; -var shape; -var idx; -var i; -var j; - -shape = [ 0, 0, 0 ]; - -for ( i = 0; i < 100; i++ ) { - // Generate a random array shape: - shape[ 0 ] = discreteUniform( 1, 10 ); - shape[ 1 ] = discreteUniform( 1, 10 ); - shape[ 2 ] = discreteUniform( 1, 10 ); - - // Generate strides: - if ( randu() < 0.5 ) { - strides = shape2strides( shape, 'row-major' ); - } else { - strides = shape2strides( shape, 'column-major' ); - } - j = discreteUniform( 0, shape.length-1 ); - strides[ j ] *= ( randu() < 0.5 ) ? -1 : 1; - - // Compute the index offset: - offset = strides2offset( shape, strides ) + 25; // include a view offset - - // Compute the minimum and maximum linear indices: - idx = minmaxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Min idx: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx[ 0 ], idx[ 1 ] ); -} diff --git a/include/stdlib/ndarray/base/minmax_view_buffer_index.h b/include/stdlib/ndarray/base/minmax_view_buffer_index.h deleted file mode 100644 index a9b760b..0000000 --- a/include/stdlib/ndarray/base/minmax_view_buffer_index.h +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H - -#include - -/* -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( const int64_t ndims, const int64_t *shape, const int64_t *strides, const int64_t offset, int64_t *out ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MINMAX_VIEW_BUFFER_INDEX_H diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index b116911..757108e 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'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f9c1421 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function r(n,r,e){var t,s,i,o,a;for(t=n.length,s=e,i=e,a=0;a0?i+=o*(n[a]-1):o<0&&(s+=o*(n[a]-1))}return[s,i]}function e(n,r,e,t){var s,i,o,a,f;for(s=n.length,i=e,o=e,f=0;f0?o+=a*(n[f]-1):a<0&&(i+=a*(n[f]-1))}return t[0]=i,t[1]=o,t}n(r,"assign",e);export{e as assign,r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7cde065 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/assign.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @returns {Array} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [ offset, offset ];\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\treturn [ min, max ];\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} linear indices\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 10, 109 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var out = [ 0, 0 ];\n* var idx = minmaxViewBufferIndex( shape, strides, offset, out );\n* // returns [ 0, 99 ]\n*\n* var bool = ( idx === out );\n* // returns true\n*/\nfunction minmaxViewBufferIndex( shape, strides, offset, out ) {\n\tvar ndims;\n\tvar min;\n\tvar max;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tmin = offset;\n\tmax = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\tout[ 0 ] = offset;\n\t\t\tout[ 1 ] = offset;\n\t\t\treturn out;\n\t\t}\n\t\ts = strides[ i ];\n\t\tif ( s > 0 ) {\n\t\t\tmax += s * ( shape[i]-1 );\n\t\t} else if ( s < 0 ) {\n\t\t\tmin += s * ( shape[i]-1 ); // decrements min\n\t\t}\n\t}\n\tout[ 0 ] = min;\n\tout[ 1 ] = max;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default minmaxViewBufferIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.\n*\n* @module @stdlib/ndarray-base-minmax-view-buffer-index\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 10;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 10, 109 ]\n*\n* @example\n* import minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = minmaxViewBufferIndex( shape, strides, offset );\n* // returns [ 0, 99 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["minmaxViewBufferIndex","shape","strides","offset","ndims","min","max","s","i","length","out","setReadOnly","main","assign"],"mappings":";;wHA8DA,SAASA,EAAuBC,EAAOC,EAASC,GAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GACX,MAAO,CAAEL,EAAQA,IAElBI,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CACD,MAAO,CAAEH,EAAKC,EACf,CCLA,SAASN,EAAuBC,EAAOC,EAASC,EAAQO,GACvD,IAAIN,EACAC,EACAC,EACAC,EACAC,EAKJ,IAHAJ,EAAQH,EAAMQ,OACdJ,EAAMF,EACNG,EAAMH,EACAK,EAAI,EAAGA,EAAIJ,EAAOI,IAAM,CAC7B,GAAoB,IAAfP,EAAOO,GAGX,OAFAE,EAAK,GAAMP,EACXO,EAAK,GAAMP,EACJO,GAERH,EAAIL,EAASM,IACJ,EACRF,GAAOC,GAAMN,EAAMO,GAAG,GACXD,EAAI,IACfF,GAAOE,GAAMN,EAAMO,GAAG,GAEvB,CAGD,OAFAE,EAAK,GAAML,EACXK,EAAK,GAAMJ,EACJI,CACR,CC9BAC,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 6a3179a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view and assigns results to a provided output array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {(Array|TypedArray|Object)} out - output object -* @returns {(Array|TypedArray|Object)} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 10, 109 ] -* -* var bool = ( idx === out ); -* // returns true -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var out = [ 0, 0 ]; -* var idx = minmaxViewBufferIndex( shape, strides, offset, out ); -* // returns [ 0, 99 ] -* -* var bool = ( idx === out ); -* // returns true -*/ -function minmaxViewBufferIndex( shape, strides, offset, out ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return out; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - return out; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1a11639..0000000 --- a/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @module @stdlib/ndarray-base-minmax-view-buffer-index -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 457cef1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Computes the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {Array} linear indices -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 10; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 10, 109 ] -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = minmaxViewBufferIndex( shape, strides, offset ); -* // returns [ 0, 99 ] -*/ -function minmaxViewBufferIndex( shape, strides, offset ) { - var ndims; - var min; - var max; - var s; - var i; - - ndims = shape.length; - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return [ offset, offset ]; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - return [ min, max ]; -} - - -// EXPORTS // - -module.exports = minmaxViewBufferIndex; diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 04e61e3..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] -} diff --git a/package.json b/package.json index f6c62bf..31b0901 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,8 @@ "version": "0.2.2", "description": "Compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view.", "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", - "include": "./include", - "lib": "./lib", - "src": "./src", - "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", @@ -38,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer-array": "^0.2.2", - "@stdlib/ndarray-base-max-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-min-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "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", @@ -96,9 +36,8 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c deleted file mode 100644 index abf3fae..0000000 --- a/src/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/ndarray/base/minmax_view_buffer_index.h" -#include - -/** -* Computes the minimum and maximum linear indices (in bytes) in an underlying data buffer accessible to an array view. -* -* @param ndims number of dimensions -* @param shape array shape (dimensions) -* @param strides array strides (in bytes) -* @param offset index offset -* @param out 2-element output array -* @return status code -* -* @example -* #include "stdlib/ndarray/base/minmax_view_buffer_index.h" -* #include -* -* int64_t ndims = 2; -* int64_t shape[] = { 10, 10 }; -* int64_t strides[] = { 10, 1 }; -* int64_t offset = 0; -* int64_t out[ 2 ]; -* -* stdlib_ndarray_minmax_view_buffer_index( ndims, shape, strides, offset, out ); -* -* int64_t min = out[ 0 ]; -* // returns 0 -* -* int64_t max = out[ 1 ]; -* // returns 99 -*/ -int8_t stdlib_ndarray_minmax_view_buffer_index( const int64_t ndims, const int64_t *shape, const int64_t *strides, const int64_t offset, int64_t *out ) { - int64_t min; - int64_t max; - int64_t s; - int64_t i; - - min = offset; - max = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - out[ 0 ] = offset; - out[ 1 ] = offset; - return 0; - } - s = strides[ i ]; - if ( s > 0 ) { - max += s * ( shape[i]-1 ); - } else if ( s < 0 ) { - min += s * ( shape[i]-1 ); // decrements min - } - } - out[ 0 ] = min; - out[ 1 ] = max; - - return 0; -} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b00d034 --- /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 103e689..0000000 --- a/test/test.js +++ /dev/null @@ -1,336 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var minmaxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minmaxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (buffer offset)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 2 ]; - - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 15, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the main function is a method which supports providing an output object', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - shape = [ 3, 2 ]; - - out = [ 0, 0 ]; - strides = [ 2, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, 1 ]; - offset = 4; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 1; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -2, -1 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, 3 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, 3 ]; - offset = 2; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 1, -3 ]; - offset = 3; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ -1, -3 ]; - offset = 5; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - out = [ 0, 0 ]; - strides = [ 30, 10, 1 ]; - offset = 0; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - out = [ 0, 0 ]; - strides = [ 30, -10, 1 ]; - offset = 20; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 0, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the provided offset when one or more dimensions is zero (assign)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - var out; - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - strides = [ 2, 1 ]; - offset = 10; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 14, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 14, 'returns expected value' ); - - out = [ 0, 0 ]; - shape = [ 3, 0 ]; - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = minmaxViewBufferIndex.assign( shape, strides, offset, out ); - t.strictEqual( idx, out, 'returns expected value' ); - t.strictEqual( idx[ 0 ], 11, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 11, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the minimum and maximum linear indices in an underlying array buffer which are accessible to an array view (shape[k]=1)', function test( t ) { - var strides; - var offset; - var shape; - var idx; - - shape = [ 1, 1 ]; - - strides = [ 0, 0 ]; - offset = 10; - - idx = minmaxViewBufferIndex( shape, strides, offset ); - t.strictEqual( isArray( idx ), true, 'returns an array' ); - t.strictEqual( idx[ 0 ], 10, 'returns expected value' ); - t.strictEqual( idx[ 1 ], 10, 'returns expected value' ); - - t.end(); -});