From 33c93bab707856d4d532ea35b6449c02f9a1daae Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Apr 2022 08:22:09 +0000 Subject: [PATCH 001/146] Auto-generated commit 49f69bd7727f7438d00bcb72352e8d5834ffcf76 --- CONTRIBUTORS | 28 + LICENSE | 481 +++++++++ NOTICE | 1 + README.md | 243 +++++ bundle.js | 3 + bundle.js.map | 1 + package.json | 39 + stats.html | 2689 +++++++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 3485 insertions(+) create mode 100644 CONTRIBUTORS create mode 100644 LICENSE create mode 100644 NOTICE create mode 100644 README.md create mode 100644 bundle.js create mode 100644 bundle.js.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..0f8046f --- /dev/null +++ b/README.md @@ -0,0 +1,243 @@ + + +# Max View Buffer Index + +[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] + +> Compute the maximum linear index in an underlying data buffer accessible to an array view. + + + +
+ +
+ + + + + + + +
+ +## Usage + +To use in Observable, + +```javascript +maxViewBufferIndex = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-max-view-buffer-index@umd/bundle.js' ) +``` + +To include the bundle in a webpage, + +```html + +``` + +If no recognized module system is present, access bundle contents via the global scope: + +```html + +``` + +#### maxViewBufferIndex( shape, strides, offset ) + +Computes the maximum linear index in an underlying data buffer 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 = maxViewBufferIndex( shape, strides, offset ); +// returns 3 +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```html + + + + + + + + + + + +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + +
+ +* * * + +## Notice + +This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. + +For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. + +#### Community + +[![Chat][chat-image]][chat-url] + +--- + +## License + +See [LICENSE][stdlib-license]. + + +## Copyright + +Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. + +
+ + + + + + + + diff --git a/bundle.js b/bundle.js new file mode 100644 index 0000000..1e23a10 --- /dev/null +++ b/bundle.js @@ -0,0 +1,3 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n()}(this,(function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}})); +//# sourceMappingURL=bundle.js.map diff --git a/bundle.js.map b/bundle.js.map new file mode 100644 index 0000000..0c0480a --- /dev/null +++ b/bundle.js.map @@ -0,0 +1 @@ +{"version":3,"file":"bundle.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";0PA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,IAGvC,OAAOD"} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..36d0ff9 --- /dev/null +++ b/package.json @@ -0,0 +1,39 @@ +{ + "name": "@stdlib/ndarray-base-max-view-buffer-index", + "version": "0.0.0", + "description": "Compute the maximum linear index in an underlying data buffer accessible to an array view.", + "license": "Apache-2.0", + "main": "./bundle.js", + "homepage": "https://stdlib.io", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/ndarray-base-max-view-buffer-index.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "keywords": [ + "stdlib", + "stdtypes", + "types", + "base", + "ndarray", + "strides", + "maximum", + "max", + "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..8db49ff --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + From 2702fae02945599bb99a498b39349541b7367757 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 30 Jun 2022 21:28:06 +0000 Subject: [PATCH 002/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index cec8fa3..965cd7f 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^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-nonnegative-integer": "^0.0.x", @@ -93,4 +94,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 0b3da88a03dcab36d88272b365284eccd1bcb5e2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 11:19:46 +0000 Subject: [PATCH 003/146] Remove files --- bundle.js | 3 - bundle.js.map | 1 - stats.html | 2689 ------------------------------------------------- 3 files changed, 2693 deletions(-) delete mode 100644 bundle.js delete mode 100644 bundle.js.map delete mode 100644 stats.html diff --git a/bundle.js b/bundle.js deleted file mode 100644 index 1e23a10..0000000 --- a/bundle.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n()}(this,(function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}})); -//# sourceMappingURL=bundle.js.map diff --git a/bundle.js.map b/bundle.js.map deleted file mode 100644 index 0c0480a..0000000 --- a/bundle.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"bundle.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";0PA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,IAGvC,OAAOD"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8db49ff..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 1d26b0d45e90c049ff5cd06d347ae9378c728e03 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 11:20:40 +0000 Subject: [PATCH 004/146] 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 | 60 +- benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - browser.js | 3 + browser.js.map | 1 + docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 2689 +++++++++++++++++ stats_node.html | 2689 +++++++++++++++++ test/test.js | 155 - 45 files changed, 5427 insertions(+), 4023 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 create mode 100644 browser.js create mode 100644 browser.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 b9d1f50..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-06-30T21:27:00.314Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 11d58b2..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/max-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 5d42a48..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/max-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 +``` + +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -98,12 +106,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b5321be..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 e6faa0e..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 `max_view_buffer_index`. -*/ -#include -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 35bdef3..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/max-view-buffer-index" -click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..c7726ea --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..269d555 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,IAGvC,OAAOD"} \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index ffe8888..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index fe4b673..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The function does not compile if provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..5981750 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..c77977d --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,IAGvC,OAAOD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 965cd7f..5739acc 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.0.8", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./browser.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.x", - "@stdlib/utils-library-manifest": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/bench": "^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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..2a8dabb --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..27b632f --- /dev/null +++ b/stats_node.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From 5d4b45fc1e45cfbc1d2643bf11e8754c0d2f1a47 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 17:20:39 +0000 Subject: [PATCH 005/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index cec8fa3..965cd7f 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^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-nonnegative-integer": "^0.0.x", @@ -93,4 +94,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 63313bb7b13987e457fdbd0b9dbff090df36e748 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 09:57:14 +0000 Subject: [PATCH 006/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 2689 -------------------------------------------- stats_node.html | 2689 -------------------------------------------- 6 files changed, 5386 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index c7726ea..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 269d555..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,IAGvC,OAAOD"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 5981750..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index c77977d..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,IAGvC,OAAOD"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index 2a8dabb..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 27b632f..0000000 --- a/stats_node.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 1b236fc6ace25d840d66a0b9725329d99301e54d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 09:58:10 +0000 Subject: [PATCH 007/146] 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 | 60 +- benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - browser.js | 3 + browser.js.map | 1 + docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 2689 +++++++++++++++++ stats_node.html | 2689 +++++++++++++++++ test/test.js | 155 - 45 files changed, 5427 insertions(+), 4023 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 create mode 100644 browser.js create mode 100644 browser.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 5303f31..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-07-01T00:46:50.835Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 11d58b2..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/max-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 5d42a48..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/max-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 +``` + +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -98,12 +106,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b5321be..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 e6faa0e..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 `max_view_buffer_index`. -*/ -#include -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 35bdef3..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/max-view-buffer-index" -click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..c7726ea --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..269d555 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,IAGvC,OAAOD"} \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index ffe8888..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index fe4b673..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The function does not compile if provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..5981750 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..c77977d --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,IAGvC,OAAOD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 965cd7f..5739acc 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.0.8", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./browser.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.x", - "@stdlib/utils-library-manifest": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/bench": "^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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..c45d543 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..cf4b11f --- /dev/null +++ b/stats_node.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From 910a7a662e029d0fc38007c103adf2d34666f618 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 18:35:10 +0000 Subject: [PATCH 008/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index cec8fa3..965cd7f 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^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-nonnegative-integer": "^0.0.x", @@ -93,4 +94,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From db184b150ca2e218c60b975ec16a1773a6d7f4b3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 19:06:19 +0000 Subject: [PATCH 009/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 2689 -------------------------------------------- stats_node.html | 2689 -------------------------------------------- 6 files changed, 5386 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index c7726ea..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 269d555..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,IAGvC,OAAOD"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 5981750..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index c77977d..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,IAGvC,OAAOD"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index c45d543..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index cf4b11f..0000000 --- a/stats_node.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 90eaf69823f21e1641121a4d1967e687a863b9af Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 19:07:22 +0000 Subject: [PATCH 010/146] 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 | 60 +- benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - browser.js | 3 + browser.js.map | 1 + docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 2689 +++++++++++++++++ stats_node.html | 2689 +++++++++++++++++ test/test.js | 155 - 44 files changed, 5427 insertions(+), 3988 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 create mode 100644 browser.js create mode 100644 browser.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 11d58b2..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/max-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 5d42a48..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/max-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 +``` + +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -98,12 +106,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b5321be..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 e6faa0e..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 `max_view_buffer_index`. -*/ -#include -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 35bdef3..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/max-view-buffer-index" -click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..c7726ea --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..269d555 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,IAGvC,OAAOD"} \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index ffe8888..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index fe4b673..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The function does not compile if provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..5981750 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..c77977d --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,IAGvC,OAAOD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 965cd7f..2405296 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.0.8", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.x", - "@stdlib/utils-library-manifest": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/bench": "^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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..00d70f6 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..3a55407 --- /dev/null +++ b/stats_node.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From bee88f8c485b65506b24fc2f085f1730de0d7be5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 03:51:09 +0000 Subject: [PATCH 011/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index cec8fa3..965cd7f 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^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-nonnegative-integer": "^0.0.x", @@ -93,4 +94,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From d149f68a1a4a3321e9d77a465a992b68605e9a83 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 14:27:56 +0000 Subject: [PATCH 012/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 2689 -------------------------------------------- stats_node.html | 2689 -------------------------------------------- 6 files changed, 5386 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index c7726ea..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 269d555..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,IAGvC,OAAOD"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 5981750..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index c77977d..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,IAGvC,OAAOD"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index 00d70f6..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 3a55407..0000000 --- a/stats_node.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 0a12fc5877d36cf1db321530f84fc797a8864b10 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 14:29:20 +0000 Subject: [PATCH 013/146] 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 | 60 +- benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - browser.js | 3 + browser.js.map | 1 + docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 2689 +++++++++++++++++ stats_node.html | 2689 +++++++++++++++++ test/test.js | 155 - 45 files changed, 5427 insertions(+), 4062 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 create mode 100644 browser.js create mode 100644 browser.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 f6e5897..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-08-01T00:50:07.730Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 11d58b2..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/max-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 5d42a48..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/max-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 +``` + +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -98,12 +106,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b5321be..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 e6faa0e..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 `max_view_buffer_index`. -*/ -#include -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 35bdef3..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/max-view-buffer-index" -click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..c7726ea --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..269d555 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,IAGvC,OAAOD"} \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index ffe8888..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index fe4b673..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The function does not compile if provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..5981750 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..c77977d --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,IAGvC,OAAOD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 965cd7f..2405296 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.0.8", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.x", - "@stdlib/utils-library-manifest": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/bench": "^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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..1c59c46 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..106f7b3 --- /dev/null +++ b/stats_node.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From 69f891e068d899388a0de7446995451c6dcee167 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 03:24:40 +0000 Subject: [PATCH 014/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index cec8fa3..965cd7f 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^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-nonnegative-integer": "^0.0.x", @@ -93,4 +94,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 94f3d308908a9781c63e1175db812b15c5e2ae6f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 10:24:52 +0000 Subject: [PATCH 015/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 2689 -------------------------------------------- stats_node.html | 2689 -------------------------------------------- 6 files changed, 5386 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index c7726ea..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 269d555..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,IAGvC,OAAOD"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 5981750..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index c77977d..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,IAGvC,OAAOD"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index 1c59c46..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 106f7b3..0000000 --- a/stats_node.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 9d23ef5623682ed0beaf8cca315d132fca6d1bdc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 10:25:34 +0000 Subject: [PATCH 016/146] 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 | 60 +- benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - browser.js | 3 + browser.js.map | 1 + docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 2689 +++++++++++++++++ stats_node.html | 2689 +++++++++++++++++ test/test.js | 155 - 45 files changed, 5427 insertions(+), 4078 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 create mode 100644 browser.js create mode 100644 browser.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 e07b25c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-09-01T00:45:59.169Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 11d58b2..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/max-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 5d42a48..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/max-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 +``` + +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -98,12 +106,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b5321be..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 e6faa0e..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 `max_view_buffer_index`. -*/ -#include -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 35bdef3..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/max-view-buffer-index" -click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..c7726ea --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..269d555 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,IAGvC,OAAOD"} \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index ffe8888..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index fe4b673..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The function does not compile if provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..5981750 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..c77977d --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,IAGvC,OAAOD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 965cd7f..2405296 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.0.8", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.x", - "@stdlib/utils-library-manifest": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/bench": "^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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..635b4f5 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..010e4d7 --- /dev/null +++ b/stats_node.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From 471f8b2cde5edc88a25bf451533d28dc5e8cc8be Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 03:39:16 +0000 Subject: [PATCH 017/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index cec8fa3..965cd7f 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^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-nonnegative-integer": "^0.0.x", @@ -93,4 +94,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From c6e6abdcb3bf93d68b7ef10bfe85a2d976d36b7f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 14:44:42 +0000 Subject: [PATCH 018/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 2689 -------------------------------------------- stats_node.html | 2689 -------------------------------------------- 6 files changed, 5386 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index c7726ea..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 269d555..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,IAGvC,OAAOD"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 5981750..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index c77977d..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,IAGvC,OAAOD"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index 635b4f5..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 010e4d7..0000000 --- a/stats_node.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From f408537a4c48c774efe86029fdccfffdb955dc62 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 14:45:49 +0000 Subject: [PATCH 019/146] 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 | 60 +- benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - browser.js | 3 + browser.js.map | 1 + docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 2689 +++++++++++++++++ stats_node.html | 2689 +++++++++++++++++ test/test.js | 155 - 45 files changed, 5427 insertions(+), 4078 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 create mode 100644 browser.js create mode 100644 browser.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 d7f9e74..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-10-01T01:10:25.344Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 11d58b2..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/max-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 5d42a48..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/max-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 +``` + +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -98,12 +106,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b5321be..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 e6faa0e..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 `max_view_buffer_index`. -*/ -#include -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 35bdef3..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/max-view-buffer-index" -click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..c7726ea --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..269d555 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,IAGvC,OAAOD"} \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index ffe8888..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..5981750 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..c77977d --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,IAGvC,OAAOD"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 965cd7f..2405296 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.0.8", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.x", - "@stdlib/utils-library-manifest": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/bench": "^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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..ac2a1b6 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..12e2600 --- /dev/null +++ b/stats_node.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From 4f8c4b517a8e5f33fc21975414ddc6a465692fdd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 03:24:33 +0000 Subject: [PATCH 020/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index cec8fa3..965cd7f 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^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-nonnegative-integer": "^0.0.x", @@ -93,4 +94,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 69ae5b476753dc51746b5bd0d89d7bb61d651031 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 13:53:12 +0000 Subject: [PATCH 021/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 2689 -------------------------------------------- stats_node.html | 2689 -------------------------------------------- 6 files changed, 5386 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index c7726ea..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 269d555..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,IAGvC,OAAOD"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 5981750..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index c77977d..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,IAGvC,OAAOD"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index ac2a1b6..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 12e2600..0000000 --- a/stats_node.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 66ed5a176708ab48a0c2cc8b1c6b74ffd8fd0ce9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 13:54:02 +0000 Subject: [PATCH 022/146] 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 | 60 +- benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - browser.js | 3 + browser.js.map | 1 + docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 4044 +++++++++++++++++ stats_node.html | 4044 +++++++++++++++++ test/test.js | 155 - 45 files changed, 8137 insertions(+), 4078 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 create mode 100644 browser.js create mode 100644 browser.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 75b776b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-01T00:56:51.532Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 11d58b2..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/max-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 5d42a48..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/max-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 49360a4..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: '33 21 * * 3' - - # 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 +``` + +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -98,12 +106,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b5321be..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 e6faa0e..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 `max_view_buffer_index`. -*/ -#include -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 35bdef3..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/max-view-buffer-index" -click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..c7726ea --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index ffe8888..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..5981750 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 965cd7f..2405296 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.0.8", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.x", - "@stdlib/utils-library-manifest": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/bench": "^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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..a7a5da8 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..3080af2 --- /dev/null +++ b/stats_node.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From 0f385e102fc145165e2c68052e8efb3df4e0b0ff Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 3 Nov 2022 21:10:08 +0000 Subject: [PATCH 023/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index cec8fa3..965cd7f 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^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-nonnegative-integer": "^0.0.x", @@ -93,4 +94,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From f7768da2780168855de4fef33b4e7782bb1bc18d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 06:47:07 +0000 Subject: [PATCH 024/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 4044 -------------------------------------------- stats_node.html | 4044 -------------------------------------------- 6 files changed, 8096 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index c7726ea..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 3ff4229..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 5981750..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index 28b42dc..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index a7a5da8..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 3080af2..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 008f32094480672ce5e8721b288eafef12576c19 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 06:47:53 +0000 Subject: [PATCH 025/146] 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 | 60 +- benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - browser.js | 3 + browser.js.map | 1 + docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 4044 +++++++++++++++++ stats_node.html | 4044 +++++++++++++++++ test/test.js | 155 - 45 files changed, 8137 insertions(+), 4099 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 create mode 100644 browser.js create mode 100644 browser.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 b5e5202..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-03T21:08:35.365Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 11d58b2..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/max-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 5d42a48..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/max-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 49360a4..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: '33 21 * * 3' - - # 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 +``` + +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -98,12 +106,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b5321be..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 e6faa0e..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 `max_view_buffer_index`. -*/ -#include -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 35bdef3..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/max-view-buffer-index" -click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..c7726ea --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index ffe8888..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..5981750 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 965cd7f..2405296 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.0.8", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.x", - "@stdlib/utils-library-manifest": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/bench": "^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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..6abfdea --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..474d02a --- /dev/null +++ b/stats_node.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From f1cdc9b6c6f38ed5b3b35c9f7261d3c2eacf2687 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 03:26:10 +0000 Subject: [PATCH 026/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 45843f7..2af9a9e 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^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-nonnegative-integer": "^0.0.x", @@ -93,4 +94,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 1e8e02139415449c5f7cb27acb7ca2c6dcbc5246 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 16:36:31 +0000 Subject: [PATCH 027/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 4044 -------------------------------------------- stats_node.html | 4044 -------------------------------------------- 6 files changed, 8096 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index c7726ea..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 3ff4229..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 5981750..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index 28b42dc..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index 6abfdea..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 474d02a..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From cced082a52117974e2f8f5ace838711bd5e5772f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 16:37:19 +0000 Subject: [PATCH 028/146] 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 | 60 +- benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - browser.js | 3 + browser.js.map | 1 + docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 4044 +++++++++++++++++ stats_node.html | 4044 +++++++++++++++++ test/test.js | 155 - 45 files changed, 8137 insertions(+), 4104 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 create mode 100644 browser.js create mode 100644 browser.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 2ab67a3..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-12-01T00:58:56.562Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 11d58b2..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/max-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 5d42a48..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/max-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 49360a4..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: '33 21 * * 3' - - # 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 +``` + +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -98,12 +106,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b5321be..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 e6faa0e..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 `max_view_buffer_index`. -*/ -#include -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 35bdef3..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/max-view-buffer-index" -click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..c7726ea --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index ffe8888..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..5981750 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 2af9a9e..2405296 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.0.8", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.x", - "@stdlib/utils-library-manifest": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/bench": "^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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..e504cc2 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..1275ebb --- /dev/null +++ b/stats_node.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From 478fb8fd6ec6f293932360655c2a55223c7769ce Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 00:53:27 +0000 Subject: [PATCH 029/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e64c833..2300e17 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^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-nonnegative-integer": "^0.0.x", @@ -93,4 +94,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 31b5a0a81dd90433029c0f03f924525af3b2c073 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 06:59:33 +0000 Subject: [PATCH 030/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 4044 -------------------------------------------- stats_node.html | 4044 -------------------------------------------- 6 files changed, 8096 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index c7726ea..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 3ff4229..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 5981750..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index 28b42dc..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index e504cc2..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 1275ebb..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 00d0cba85a97a3737c2068c627221eb0d5710976 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 07:00:37 +0000 Subject: [PATCH 031/146] 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 | 60 +- benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - browser.js | 3 + browser.js.map | 1 + docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 4044 +++++++++++++++++ stats_node.html | 4044 +++++++++++++++++ test/test.js | 155 - 45 files changed, 8137 insertions(+), 4115 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 create mode 100644 browser.js create mode 100644 browser.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 db5405e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-01-01T00:46:05.720Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 11d58b2..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/max-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 5d42a48..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/max-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 49360a4..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: '33 21 * * 3' - - # 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 +``` + +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -98,12 +106,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b5321be..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 e6faa0e..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 `max_view_buffer_index`. -*/ -#include -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 35bdef3..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/max-view-buffer-index" -click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..55c4a84 --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index ffe8888..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..20446af --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 2300e17..2405296 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.0.8", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.x", - "@stdlib/utils-library-manifest": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/bench": "^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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..c9d420b --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..f330eee --- /dev/null +++ b/stats_node.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From 99d634365a87080864c0e8f3a53dac93546872c4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 03:28:33 +0000 Subject: [PATCH 032/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e64c833..2300e17 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^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-nonnegative-integer": "^0.0.x", @@ -93,4 +94,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 4ae11d18d328ae9fef0b39b8b018c55db1034efa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 08:26:34 +0000 Subject: [PATCH 033/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 4044 -------------------------------------------- stats_node.html | 4044 -------------------------------------------- 6 files changed, 8096 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index 55c4a84..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 3ff4229..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 20446af..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index 28b42dc..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index c9d420b..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index f330eee..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 087dd6cd43d1bf933a482c3cb99721d44153a7fd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 08:27:27 +0000 Subject: [PATCH 034/146] 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 | 60 +- benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - browser.js | 3 + browser.js.map | 1 + docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 6177 +++++++++++++++++ stats_node.html | 6177 +++++++++++++++++ test/test.js | 155 - 45 files changed, 12403 insertions(+), 4115 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 create mode 100644 browser.js create mode 100644 browser.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 5006ee9..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-02-01T00:55:27.603Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 11d58b2..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/max-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 5d42a48..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/max-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 49360a4..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: '33 21 * * 3' - - # 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 +``` + +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -98,12 +106,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b5321be..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 e6faa0e..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 `max_view_buffer_index`. -*/ -#include -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 35bdef3..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/max-view-buffer-index" -click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..55c4a84 --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index ffe8888..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..20446af --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 2300e17..2405296 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.0.8", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.x", - "@stdlib/utils-library-manifest": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/bench": "^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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..6ac0fec --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..e285c5e --- /dev/null +++ b/stats_node.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From 3b06098092b31e79102766762ffb89b9f78a58a7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 02:22:11 +0000 Subject: [PATCH 035/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9e0b027..bc7b91c 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^0.0.14", - "@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-nonnegative-integer": "^0.0.7", @@ -93,4 +94,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From fd52fdb26241a0dabc49aa9ac1fcaa9bf1b75d8f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 05:43:28 +0000 Subject: [PATCH 036/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 6177 -------------------------------------------- stats_node.html | 6177 -------------------------------------------- 6 files changed, 12362 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index 55c4a84..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 3ff4229..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 20446af..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index 28b42dc..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index 6ac0fec..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index e285c5e..0000000 --- a/stats_node.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 95bc84954cbf759e97d5fe69e0de0f4fe399b2aa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 05:44:24 +0000 Subject: [PATCH 037/146] 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 | 60 +- benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - browser.js | 3 + browser.js.map | 1 + docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 6177 +++++++++++++++++ stats_node.html | 6177 +++++++++++++++++ test/test.js | 155 - 45 files changed, 12403 insertions(+), 4250 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 create mode 100644 browser.js create mode 100644 browser.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 bae5fa6..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-03-01T01:34:35.223Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 11d58b2..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/max-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 5d42a48..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/max-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 49360a4..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: '33 21 * * 3' - - # 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 +``` + +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -98,12 +106,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b5321be..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 e6faa0e..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 `max_view_buffer_index`. -*/ -#include -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 d6132d6..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/max-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..55c4a84 --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index ffe8888..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..20446af --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 bc7b91c..f7a7acc 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.0.8", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.14", - "@stdlib/utils-library-manifest": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/bench": "^0.0.12", - "@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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..853971e --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..01dbe00 --- /dev/null +++ b/stats_node.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From b8b1aa861545fac5c2e4d68f9a5fcc42154e8096 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 02:24:29 +0000 Subject: [PATCH 038/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9e0b027..bc7b91c 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^0.0.14", - "@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-nonnegative-integer": "^0.0.7", @@ -93,4 +94,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 41d5eca2f74bd990da594532e2b20e52b5cfe205 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 05:31:34 +0000 Subject: [PATCH 039/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 6177 -------------------------------------------- stats_node.html | 6177 -------------------------------------------- 6 files changed, 12362 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index 55c4a84..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 3ff4229..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 20446af..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index 28b42dc..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index 853971e..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 01dbe00..0000000 --- a/stats_node.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 08389820181c696a638070c54df57bcc7d5ea945 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 05:32:40 +0000 Subject: [PATCH 040/146] 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 | 60 +- benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - browser.js | 3 + browser.js.map | 1 + docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 6177 +++++++++++++++++ stats_node.html | 6177 +++++++++++++++++ test/test.js | 155 - 45 files changed, 12403 insertions(+), 4256 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 create mode 100644 browser.js create mode 100644 browser.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 e4a998f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-04-01T01:40:51.229Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 11d58b2..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/max-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 5d42a48..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/max-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 49360a4..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: '33 21 * * 3' - - # 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 +``` + +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -98,12 +106,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b5321be..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 e6faa0e..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 `max_view_buffer_index`. -*/ -#include -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 d6132d6..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/max-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..55c4a84 --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index ffe8888..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..20446af --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 bc7b91c..f7a7acc 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.0.8", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.14", - "@stdlib/utils-library-manifest": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/bench": "^0.0.12", - "@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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..602fe08 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..11d3fce --- /dev/null +++ b/stats_node.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From 58c4f8507b96b822b9efa6834eb43069f32fb376 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 02:19:18 +0000 Subject: [PATCH 041/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9e0b027..bc7b91c 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^0.0.14", - "@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-nonnegative-integer": "^0.0.7", @@ -93,4 +94,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 10af9b54eef864c8abb35d48cbf75321d904628c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 05:20:18 +0000 Subject: [PATCH 042/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 6177 -------------------------------------------- stats_node.html | 6177 -------------------------------------------- 6 files changed, 12362 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index 55c4a84..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 3ff4229..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 20446af..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index 28b42dc..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index 602fe08..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 11d3fce..0000000 --- a/stats_node.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From eb0b87d58b99c22959d7059ceb0a6f7d758e7c72 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 05:21:13 +0000 Subject: [PATCH 043/146] 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 | 60 +- benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - browser.js | 3 + browser.js.map | 1 + docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 6177 +++++++++++++++++ stats_node.html | 6177 +++++++++++++++++ test/test.js | 155 - 45 files changed, 12403 insertions(+), 4256 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 create mode 100644 browser.js create mode 100644 browser.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 eda6aec..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-05-01T01:37:25.958Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 11d58b2..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/max-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 5d42a48..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/max-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 49360a4..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: '33 21 * * 3' - - # 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 +``` + +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -98,12 +106,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b5321be..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 e6faa0e..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 `max_view_buffer_index`. -*/ -#include -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 d6132d6..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/max-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..55c4a84 --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index ffe8888..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..20446af --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 bc7b91c..f7a7acc 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.0.8", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.14", - "@stdlib/utils-library-manifest": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/bench": "^0.0.12", - "@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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..d8bb62f --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..4c6b2d1 --- /dev/null +++ b/stats_node.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From a8155a8e131ec76e456bf5657170c1671b629382 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 02:20:37 +0000 Subject: [PATCH 044/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9e0b027..bc7b91c 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^0.0.14", - "@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-nonnegative-integer": "^0.0.7", @@ -93,4 +94,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 2fb59616fc3c183dfdb44956fd9ed4330556f51b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 05:33:23 +0000 Subject: [PATCH 045/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 6177 -------------------------------------------- stats_node.html | 6177 -------------------------------------------- 6 files changed, 12362 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index 55c4a84..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 3ff4229..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 20446af..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index 28b42dc..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index d8bb62f..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 4c6b2d1..0000000 --- a/stats_node.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c930a6071ce0d8b7d2e2e6486d15e291ba6af121 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 05:34:23 +0000 Subject: [PATCH 046/146] 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 | 60 +- benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - browser.js | 3 + browser.js.map | 1 + docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 6177 +++++++++++++++++ stats_node.html | 6177 +++++++++++++++++ test/test.js | 155 - 45 files changed, 12403 insertions(+), 4256 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 create mode 100644 browser.js create mode 100644 browser.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 7f2fda3..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-06-01T01:37:36.430Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 11d58b2..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/max-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 5d42a48..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/max-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 49360a4..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: '33 21 * * 3' - - # 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 +``` + +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -98,12 +106,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b5321be..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 e6faa0e..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 `max_view_buffer_index`. -*/ -#include -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 d6132d6..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/max-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..55c4a84 --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index ffe8888..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..20446af --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 bc7b91c..f7a7acc 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.0.8", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.14", - "@stdlib/utils-library-manifest": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/bench": "^0.0.12", - "@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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..7f3621a --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..720b9c3 --- /dev/null +++ b/stats_node.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From 1ec3e882f1886809f3def689112c2172661cd074 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 02:20:34 +0000 Subject: [PATCH 047/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9e0b027..bc7b91c 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^0.0.14", - "@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-nonnegative-integer": "^0.0.7", @@ -93,4 +94,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 9042c0021354ed2e5a98821cbcc104485593c9af Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 05:40:18 +0000 Subject: [PATCH 048/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 6177 -------------------------------------------- stats_node.html | 6177 -------------------------------------------- 6 files changed, 12362 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index 55c4a84..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 3ff4229..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 20446af..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index 28b42dc..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index 7f3621a..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 720b9c3..0000000 --- a/stats_node.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 2fbbe2d4f045dab7bf0321b82f79c44f7f6e9a3c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 05:41:16 +0000 Subject: [PATCH 049/146] 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 | 60 +- benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - browser.js | 3 + browser.js.map | 1 + docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 6177 +++++++++++++++++ stats_node.html | 6177 +++++++++++++++++ test/test.js | 155 - 45 files changed, 12403 insertions(+), 4256 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 create mode 100644 browser.js create mode 100644 browser.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 a895be6..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-07-01T01:37:48.512Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 11d58b2..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/max-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 5d42a48..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/max-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 49360a4..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: '33 21 * * 3' - - # 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 +``` + +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -98,12 +106,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b5321be..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 e6faa0e..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 `max_view_buffer_index`. -*/ -#include -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 d6132d6..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/max-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..55c4a84 --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index ffe8888..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..20446af --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 bc7b91c..f7a7acc 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.0.8", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.14", - "@stdlib/utils-library-manifest": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/bench": "^0.0.12", - "@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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..6fab87d --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..93e2ded --- /dev/null +++ b/stats_node.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From 38afd67133c5dee54553519f64da21370236eea4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 02:29:22 +0000 Subject: [PATCH 050/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9e0b027..bc7b91c 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^0.0.14", - "@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-nonnegative-integer": "^0.0.7", @@ -93,4 +94,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From ff00dce1839d894a8f316b85c47444ce421f5eb4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 05:50:39 +0000 Subject: [PATCH 051/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 6177 -------------------------------------------- stats_node.html | 6177 -------------------------------------------- 6 files changed, 12362 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index 55c4a84..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 3ff4229..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 20446af..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index 28b42dc..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index 6fab87d..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 93e2ded..0000000 --- a/stats_node.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c431f2355b3cd3b180bdfc303021f1746113a62d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 05:51:42 +0000 Subject: [PATCH 052/146] 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 | 60 +- benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - browser.js | 3 + browser.js.map | 1 + docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 6177 +++++++++++++++++ stats_node.html | 6177 +++++++++++++++++ test/test.js | 155 - 45 files changed, 12403 insertions(+), 4256 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 create mode 100644 browser.js create mode 100644 browser.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 ba10287..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-08-01T01:40:40.668Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 11d58b2..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/max-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 5d42a48..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/max-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 49360a4..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: '33 21 * * 3' - - # 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 +``` + +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -98,12 +106,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b5321be..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 e6faa0e..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 `max_view_buffer_index`. -*/ -#include -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 d6132d6..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/max-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..55c4a84 --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index ffe8888..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..20446af --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 bc7b91c..f7a7acc 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.0.8", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.14", - "@stdlib/utils-library-manifest": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/bench": "^0.0.12", - "@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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..0180d70 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..639cfba --- /dev/null +++ b/stats_node.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From cf521b563cb098420e4511925208077f2cbe681f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 22 Sep 2023 23:16:18 +0000 Subject: [PATCH 053/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 639753d..e68b40b 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^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-nonnegative-integer": "^0.0.7", @@ -93,4 +94,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 6abf2801e7888cf6025969d2e203c0888f469428 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 22 Sep 2023 23:56:36 +0000 Subject: [PATCH 054/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 6177 -------------------------------------------- stats_node.html | 6177 -------------------------------------------- 6 files changed, 12362 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index 55c4a84..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 3ff4229..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 20446af..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index 28b42dc..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index 0180d70..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 639cfba..0000000 --- a/stats_node.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 04654988d2b015ebe2d229abede0cd6a4dc214ad Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 22 Sep 2023 23:57:37 +0000 Subject: [PATCH 055/146] 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 | 60 +- benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 6177 +++++++++++++++++ stats_node.html | 6177 +++++++++++++++++ test/test.js | 155 - 48 files changed, 12403 insertions(+), 4290 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 create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 11d58b2..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/max-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 5d42a48..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/max-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 49360a4..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: '33 21 * * 3' - - # 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 +``` + +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -109,12 +117,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b5321be..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 e6faa0e..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 `max_view_buffer_index`. -*/ -#include -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 d6132d6..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/max-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..55c4a84 --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 5c6cc00..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import maxViewBufferIndex from '../docs/types/index'; -export = maxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9934011..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(i,r){return function(){return r||i((r={exports:{}}).exports,r),r.exports}};var f=a(function(m,x){ -function v(i,r,t){var u,n,e;for(u=i.length,n=t,e=0;e0&&(n+=r[e]*(i[e]-1))}return n}x.exports=v -});var c=f();module.exports=c; -/** @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 f54d3d9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 maximum linear index in an underlying data buffer accessible to an array view.\n*\n* @module @stdlib/ndarray-base-max-view-buffer-index\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\n\n// MODULES //\n\nvar maxViewBufferIndex = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAoBC,EAAOC,EAASC,EAAS,CACrD,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAM,OACdI,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAKL,EAAOK,CAAE,IAAM,EACnB,OAAOH,EAEHD,EAASI,CAAE,EAAI,IACnBD,GAAOH,EAASI,CAAE,GAAML,EAAOK,CAAE,EAAI,GAEvC,CACA,OAAOD,CACR,CAKAN,EAAO,QAAUC,ICfjB,IAAIO,EAAqB,IAKzB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "maxViewBufferIndex", "shape", "strides", "offset", "ndims", "idx", "i", "maxViewBufferIndex"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index d85878b..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..20446af --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 e68b40b..8e72d33 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.1.0", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.1.0", - "@stdlib/utils-library-manifest": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/bench": "^0.1.0", - "@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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..a3b2517 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..cfa545f --- /dev/null +++ b/stats_node.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From 30e2be597e9f9be6873e6e0ca93ef6de045369e9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 Sep 2023 00:20:08 +0000 Subject: [PATCH 056/146] Update README.md for UMD bundle v0.1.0 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6991a76..2e25e06 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ limitations under the License. To use in Observable, ```javascript -maxViewBufferIndex = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-max-view-buffer-index@umd/browser.js' ) +maxViewBufferIndex = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-max-view-buffer-index@v0.1.0-umd/browser.js' ) ``` To vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build: @@ -66,7 +66,7 @@ var maxViewBufferIndex = require( 'path/to/vendor/umd/ndarray-base-max-view-buff To include the bundle in a webpage, ```html - + ``` If no recognized module system is present, access bundle contents via the global scope: @@ -125,7 +125,7 @@ var idx = maxViewBufferIndex( shape, strides, offset ); - + + ``` If no recognized module system is present, access bundle contents via the global scope: @@ -125,7 +130,7 @@ var idx = maxViewBufferIndex( shape, strides, offset ); - + - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index cfa545f..0000000 --- a/stats_node.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 295eb7c706d6e50dde80a1ddaf0117d87bfd92e2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Oct 2023 21:20:35 +0000 Subject: [PATCH 060/146] 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 | 60 +- benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 6177 +++++++++++++++++ stats_node.html | 6177 +++++++++++++++++ test/dist/test.js | 155 - test/test.js | 155 - 50 files changed, 12403 insertions(+), 4504 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 create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 9c9ea06..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-10-01T01:21:58.825Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 11d58b2..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/max-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 d216ea9..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/max-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 d8f58d6..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: '33 21 * * 3' - - # 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 +``` + +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -109,12 +117,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b5321be..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 e6faa0e..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 `max_view_buffer_index`. -*/ -#include -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 d6132d6..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/max-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..55c4a84 --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 5c6cc00..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import maxViewBufferIndex from '../docs/types/index'; -export = maxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9934011..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(i,r){return function(){return r||i((r={exports:{}}).exports,r),r.exports}};var f=a(function(m,x){ -function v(i,r,t){var u,n,e;for(u=i.length,n=t,e=0;e0&&(n+=r[e]*(i[e]-1))}return n}x.exports=v -});var c=f();module.exports=c; -/** @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 f54d3d9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 maximum linear index in an underlying data buffer accessible to an array view.\n*\n* @module @stdlib/ndarray-base-max-view-buffer-index\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\n\n// MODULES //\n\nvar maxViewBufferIndex = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAoBC,EAAOC,EAASC,EAAS,CACrD,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAM,OACdI,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAKL,EAAOK,CAAE,IAAM,EACnB,OAAOH,EAEHD,EAASI,CAAE,EAAI,IACnBD,GAAOH,EAASI,CAAE,GAAML,EAAOK,CAAE,EAAI,GAEvC,CACA,OAAOD,CACR,CAKAN,EAAO,QAAUC,ICfjB,IAAIO,EAAqB,IAKzB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "maxViewBufferIndex", "shape", "strides", "offset", "ndims", "idx", "i", "maxViewBufferIndex"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index d85878b..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..20446af --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 b3d9488..8e72d33 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.1.0", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.1.0", - "@stdlib/utils-library-manifest": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/bench": "^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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..53799d3 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..b36962d --- /dev/null +++ b/stats_node.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index 84d80cc..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From 3e19078a18f9e7d92ea102d63b284acf61a58708 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 4 Oct 2023 02:31:34 +0000 Subject: [PATCH 061/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6fe9507..0f35973 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^0.1.0", - "@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-nonnegative-integer": "^0.1.0", @@ -93,4 +94,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 5db0bcf145ba39a2d2b34da0bc929b7a99363ed8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 4 Oct 2023 12:04:51 +0000 Subject: [PATCH 062/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 6177 -------------------------------------------- stats_node.html | 6177 -------------------------------------------- 6 files changed, 12362 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index 55c4a84..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 3ff4229..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 20446af..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index 28b42dc..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index 53799d3..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index b36962d..0000000 --- a/stats_node.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 3a491432617e8119572db43a5b81082a41b6eac5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 4 Oct 2023 12:08:01 +0000 Subject: [PATCH 063/146] 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 | 60 +- benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 6177 +++++++++++++++++ stats_node.html | 6177 +++++++++++++++++ test/dist/test.js | 155 - test/test.js | 155 - 49 files changed, 12403 insertions(+), 4503 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 create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 11d58b2..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/max-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 d216ea9..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/max-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 d8f58d6..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: '33 21 * * 3' - - # 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 +``` + +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -109,12 +117,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b5321be..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 e6faa0e..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 `max_view_buffer_index`. -*/ -#include -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 d6132d6..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/max-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..55c4a84 --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 5c6cc00..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import maxViewBufferIndex from '../docs/types/index'; -export = maxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9934011..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(i,r){return function(){return r||i((r={exports:{}}).exports,r),r.exports}};var f=a(function(m,x){ -function v(i,r,t){var u,n,e;for(u=i.length,n=t,e=0;e0&&(n+=r[e]*(i[e]-1))}return n}x.exports=v -});var c=f();module.exports=c; -/** @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 f54d3d9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 maximum linear index in an underlying data buffer accessible to an array view.\n*\n* @module @stdlib/ndarray-base-max-view-buffer-index\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\n\n// MODULES //\n\nvar maxViewBufferIndex = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAoBC,EAAOC,EAASC,EAAS,CACrD,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAM,OACdI,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAKL,EAAOK,CAAE,IAAM,EACnB,OAAOH,EAEHD,EAASI,CAAE,EAAI,IACnBD,GAAOH,EAASI,CAAE,GAAML,EAAOK,CAAE,EAAI,GAEvC,CACA,OAAOD,CACR,CAKAN,EAAO,QAAUC,ICfjB,IAAIO,EAAqB,IAKzB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "maxViewBufferIndex", "shape", "strides", "offset", "ndims", "idx", "i", "maxViewBufferIndex"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index d85878b..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..20446af --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 0f35973..90a6fba 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.1.1", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.1.0", - "@stdlib/utils-library-manifest": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/bench": "^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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..568fd0d --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..dcb3dce --- /dev/null +++ b/stats_node.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index 84d80cc..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From 2d1d11eb39a7b746f5e0a0c5913d298c1ba3b217 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 4 Oct 2023 16:00:15 +0000 Subject: [PATCH 064/146] Update README.md for UMD bundle v0.1.1 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 771dbc1..7070241 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ limitations under the License. To use in Observable, ```javascript -maxViewBufferIndex = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-max-view-buffer-index@umd/browser.js' ) +maxViewBufferIndex = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-max-view-buffer-index@v0.1.1-umd/browser.js' ) ``` To vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build: @@ -66,7 +66,7 @@ var maxViewBufferIndex = require( 'path/to/vendor/umd/ndarray-base-max-view-buff To include the bundle in a webpage, ```html - + ``` If no recognized module system is present, access bundle contents via the global scope: @@ -125,7 +125,7 @@ var idx = maxViewBufferIndex( shape, strides, offset ); - + + ``` If no recognized module system is present, access bundle contents via the global scope: @@ -125,7 +130,7 @@ var idx = maxViewBufferIndex( shape, strides, offset ); - + - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index dcb3dce..0000000 --- a/stats_node.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b628fc8e3dcbd3e67efca35d61a9ab539bfa4c3e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 23:03:58 +0000 Subject: [PATCH 068/146] 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 | 60 +- benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 6177 +++++++++++++++++ stats_node.html | 6177 +++++++++++++++++ test/dist/test.js | 155 - test/test.js | 155 - 49 files changed, 12403 insertions(+), 4503 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 create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 11d58b2..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/max-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 d216ea9..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/max-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 d8f58d6..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: '33 21 * * 3' - - # 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 +``` + +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -109,12 +117,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b5321be..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 e6faa0e..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 `max_view_buffer_index`. -*/ -#include -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 d6132d6..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/max-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..55c4a84 --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 5c6cc00..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import maxViewBufferIndex from '../docs/types/index'; -export = maxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9934011..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(i,r){return function(){return r||i((r={exports:{}}).exports,r),r.exports}};var f=a(function(m,x){ -function v(i,r,t){var u,n,e;for(u=i.length,n=t,e=0;e0&&(n+=r[e]*(i[e]-1))}return n}x.exports=v -});var c=f();module.exports=c; -/** @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 f54d3d9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 maximum linear index in an underlying data buffer accessible to an array view.\n*\n* @module @stdlib/ndarray-base-max-view-buffer-index\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\n\n// MODULES //\n\nvar maxViewBufferIndex = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAoBC,EAAOC,EAASC,EAAS,CACrD,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAM,OACdI,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAKL,EAAOK,CAAE,IAAM,EACnB,OAAOH,EAEHD,EAASI,CAAE,EAAI,IACnBD,GAAOH,EAASI,CAAE,GAAML,EAAOK,CAAE,EAAI,GAEvC,CACA,OAAOD,CACR,CAKAN,EAAO,QAAUC,ICfjB,IAAIO,EAAqB,IAKzB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "maxViewBufferIndex", "shape", "strides", "offset", "ndims", "idx", "i", "maxViewBufferIndex"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index d85878b..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..20446af --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 a8c66c6..90a6fba 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.1.1", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.1.0", - "@stdlib/utils-library-manifest": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..ede5a1f --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..9e30741 --- /dev/null +++ b/stats_node.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index 84d80cc..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From e20c7c7ed549dbbf2ee3b9cef9fb05cdbc3ad585 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 02:53:30 +0000 Subject: [PATCH 069/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 1a500d9..a8c66c6 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^0.1.0", - "@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-nonnegative-integer": "^0.1.0", @@ -93,4 +94,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From bb939af779978f7a36fe6cca98afd1c2adf1bdcf Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 21:05:31 +0000 Subject: [PATCH 070/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 6177 -------------------------------------------- stats_node.html | 6177 -------------------------------------------- 6 files changed, 12362 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index 55c4a84..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 3ff4229..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 20446af..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index 28b42dc..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index ede5a1f..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 9e30741..0000000 --- a/stats_node.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 460a397fba064b9e164bf0b90fd4881d52d165d4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 21:09:00 +0000 Subject: [PATCH 071/146] 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 | 60 +- benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 6177 +++++++++++++++++ stats_node.html | 6177 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 155 - 50 files changed, 12403 insertions(+), 4390 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 create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 464bbaa..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-11-01T01:22:52.665Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 11d58b2..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/max-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 d216ea9..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/max-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 d8f58d6..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: '33 21 * * 3' - - # 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 +``` + +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -109,12 +117,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b5321be..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 e6faa0e..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 `max_view_buffer_index`. -*/ -#include -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 d6132d6..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/max-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..55c4a84 --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 5c6cc00..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import maxViewBufferIndex from '../docs/types/index'; -export = maxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9934011..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(i,r){return function(){return r||i((r={exports:{}}).exports,r),r.exports}};var f=a(function(m,x){ -function v(i,r,t){var u,n,e;for(u=i.length,n=t,e=0;e0&&(n+=r[e]*(i[e]-1))}return n}x.exports=v -});var c=f();module.exports=c; -/** @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 f54d3d9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 maximum linear index in an underlying data buffer accessible to an array view.\n*\n* @module @stdlib/ndarray-base-max-view-buffer-index\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\n\n// MODULES //\n\nvar maxViewBufferIndex = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAoBC,EAAOC,EAASC,EAAS,CACrD,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAM,OACdI,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAKL,EAAOK,CAAE,IAAM,EACnB,OAAOH,EAEHD,EAASI,CAAE,EAAI,IACnBD,GAAOH,EAASI,CAAE,GAAML,EAAOK,CAAE,EAAI,GAEvC,CACA,OAAOD,CACR,CAKAN,EAAO,QAAUC,ICfjB,IAAIO,EAAqB,IAKzB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "maxViewBufferIndex", "shape", "strides", "offset", "ndims", "idx", "i", "maxViewBufferIndex"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index d85878b..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..20446af --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 a8c66c6..90a6fba 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.1.1", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.1.0", - "@stdlib/utils-library-manifest": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..f6ec65f --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..151fbe5 --- /dev/null +++ b/stats_node.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 ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From e7211d518d0cd67e0e4c247f81935743a8682268 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 02:47:04 +0000 Subject: [PATCH 072/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ea624ff..3585444 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^0.2.0", - "@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-nonnegative-integer": "^0.1.0", @@ -93,4 +94,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From ad6a1ec0ffd8ce68cc63e86fbd8968619b0bd798 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 14:45:52 +0000 Subject: [PATCH 073/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 6177 -------------------------------------------- stats_node.html | 6177 -------------------------------------------- 6 files changed, 12362 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index 55c4a84..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 3ff4229..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 20446af..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index 28b42dc..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index f6ec65f..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 151fbe5..0000000 --- a/stats_node.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 25aa98c38dc320f7ae06095368e599381eff724f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 14:48:31 +0000 Subject: [PATCH 074/146] 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 | 60 +- benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 6177 +++++++++++++++++ stats_node.html | 6177 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 155 - 50 files changed, 12403 insertions(+), 4385 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 create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 f8397d0..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-12-01T01:27:25.647Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 11d58b2..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/max-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 d216ea9..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/max-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 d8f58d6..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: '33 21 * * 3' - - # 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 +``` + +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -109,12 +117,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b5321be..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 e6faa0e..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 `max_view_buffer_index`. -*/ -#include -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 d6132d6..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/max-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..55c4a84 --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 5c6cc00..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import maxViewBufferIndex from '../docs/types/index'; -export = maxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9934011..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(i,r){return function(){return r||i((r={exports:{}}).exports,r),r.exports}};var f=a(function(m,x){ -function v(i,r,t){var u,n,e;for(u=i.length,n=t,e=0;e0&&(n+=r[e]*(i[e]-1))}return n}x.exports=v -});var c=f();module.exports=c; -/** @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 f54d3d9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 maximum linear index in an underlying data buffer accessible to an array view.\n*\n* @module @stdlib/ndarray-base-max-view-buffer-index\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\n\n// MODULES //\n\nvar maxViewBufferIndex = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAoBC,EAAOC,EAASC,EAAS,CACrD,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAM,OACdI,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAKL,EAAOK,CAAE,IAAM,EACnB,OAAOH,EAEHD,EAASI,CAAE,EAAI,IACnBD,GAAOH,EAASI,CAAE,GAAML,EAAOK,CAAE,EAAI,GAEvC,CACA,OAAOD,CACR,CAKAN,EAAO,QAAUC,ICfjB,IAAIO,EAAqB,IAKzB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "maxViewBufferIndex", "shape", "strides", "offset", "ndims", "idx", "i", "maxViewBufferIndex"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index c200e94..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..20446af --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 3585444..90a6fba 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.1.1", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.2.0", - "@stdlib/utils-library-manifest": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/bench": "^0.2.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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..3da104e --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..2e2ac2a --- /dev/null +++ b/stats_node.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 ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From cc134b654c54e06b2cc53875ea4c8513b5524968 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 02:05:23 +0000 Subject: [PATCH 075/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6b2d967..0bd0dfa 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^0.2.0", - "@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-nonnegative-integer": "^0.1.0", @@ -93,4 +94,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From b3ac79fd3cc8e8df34b5f0a97a43e248242472d9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 05:36:37 +0000 Subject: [PATCH 076/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 6177 -------------------------------------------- stats_node.html | 6177 -------------------------------------------- 6 files changed, 12362 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index 55c4a84..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 3ff4229..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 20446af..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index 28b42dc..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index 3da104e..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 2e2ac2a..0000000 --- a/stats_node.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0a5f7768209bdbef5bd278e0f0acd186a4a36b56 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 05:37:02 +0000 Subject: [PATCH 077/146] 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 | 60 +- SECURITY.md | 5 - benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 53 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 6177 +++++++++++++++++ stats_node.html | 6177 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 155 - 51 files changed, 12403 insertions(+), 4391 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 create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 10b43ea..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-01-01T01:20:12.421Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 11d58b2..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/max-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 d216ea9..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/max-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 2928cd4..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: '33 21 * * 3' - - # 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 +``` + +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -109,12 +117,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
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 f40f14b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 e6faa0e..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 `max_view_buffer_index`. -*/ -#include -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 d6132d6..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/max-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..f34e464 --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 5c6cc00..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import maxViewBufferIndex from '../docs/types/index'; -export = maxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9934011..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(i,r){return function(){return r||i((r={exports:{}}).exports,r),r.exports}};var f=a(function(m,x){ -function v(i,r,t){var u,n,e;for(u=i.length,n=t,e=0;e0&&(n+=r[e]*(i[e]-1))}return n}x.exports=v -});var c=f();module.exports=c; -/** @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 f54d3d9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 maximum linear index in an underlying data buffer accessible to an array view.\n*\n* @module @stdlib/ndarray-base-max-view-buffer-index\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\n\n// MODULES //\n\nvar maxViewBufferIndex = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAoBC,EAAOC,EAASC,EAAS,CACrD,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAM,OACdI,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAKL,EAAOK,CAAE,IAAM,EACnB,OAAOH,EAEHD,EAASI,CAAE,EAAI,IACnBD,GAAOH,EAASI,CAAE,GAAML,EAAOK,CAAE,EAAI,GAEvC,CACA,OAAOD,CACR,CAKAN,EAAO,QAAUC,ICfjB,IAAIO,EAAqB,IAKzB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "maxViewBufferIndex", "shape", "strides", "offset", "ndims", "idx", "i", "maxViewBufferIndex"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index c200e94..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..c1d8409 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 0bd0dfa..90a6fba 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.1.1", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.2.0", - "@stdlib/utils-library-manifest": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..dd1532e --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..1e15763 --- /dev/null +++ b/stats_node.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 ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From 85b04fe0bd44ee97ddd080762b5f7ad0a7f31998 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 02:07:47 +0000 Subject: [PATCH 078/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6b2d967..0bd0dfa 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^0.2.0", - "@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-nonnegative-integer": "^0.1.0", @@ -93,4 +94,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 145afeb1a8b6a57490ca0bb4b6dbef240cbb1ae6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 04:45:41 +0000 Subject: [PATCH 079/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 6177 -------------------------------------------- stats_node.html | 6177 -------------------------------------------- 6 files changed, 12362 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index f34e464..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 3ff4229..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index c1d8409..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index 28b42dc..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index dd1532e..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 1e15763..0000000 --- a/stats_node.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b32abdf51b52eaa0b1509b71c1d412e02e53c32d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 04:46:02 +0000 Subject: [PATCH 080/146] 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 | 60 +- SECURITY.md | 5 - benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 6177 +++++++++++++++++ stats_node.html | 6177 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 155 - 51 files changed, 12402 insertions(+), 4395 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 create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 01de57c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-02-01T01:28:20.705Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 11d58b2..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/max-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 d216ea9..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/max-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 2928cd4..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: '33 21 * * 3' - - # 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 +``` -```javascript -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -111,12 +117,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
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 f40f14b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 e6faa0e..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 `max_view_buffer_index`. -*/ -#include -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 b0f5a0e..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/max-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..f34e464 --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 5c6cc00..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import maxViewBufferIndex from '../docs/types/index'; -export = maxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9934011..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(i,r){return function(){return r||i((r={exports:{}}).exports,r),r.exports}};var f=a(function(m,x){ -function v(i,r,t){var u,n,e;for(u=i.length,n=t,e=0;e0&&(n+=r[e]*(i[e]-1))}return n}x.exports=v -});var c=f();module.exports=c; -/** @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 f54d3d9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 maximum linear index in an underlying data buffer accessible to an array view.\n*\n* @module @stdlib/ndarray-base-max-view-buffer-index\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\n\n// MODULES //\n\nvar maxViewBufferIndex = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAoBC,EAAOC,EAASC,EAAS,CACrD,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAM,OACdI,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAKL,EAAOK,CAAE,IAAM,EACnB,OAAOH,EAEHD,EAASI,CAAE,EAAI,IACnBD,GAAOH,EAASI,CAAE,GAAML,EAAOK,CAAE,EAAI,GAEvC,CACA,OAAOD,CACR,CAKAN,EAAO,QAAUC,ICfjB,IAAIO,EAAqB,IAKzB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "maxViewBufferIndex", "shape", "strides", "offset", "ndims", "idx", "i", "maxViewBufferIndex"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index c200e94..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..c1d8409 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 0bd0dfa..90a6fba 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.1.1", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.2.0", - "@stdlib/utils-library-manifest": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..4e38cc4 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..5813a95 --- /dev/null +++ b/stats_node.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 ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From b811703fe42c80ee81885e16b07c36498bb21bc7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 05:08:40 +0000 Subject: [PATCH 081/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e810d28..0c1e4d4 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^0.3.1", - "@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-nonnegative-integer": "^0.1.0", @@ -93,4 +94,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 1fe87a5eb1d234b3fc29d1d3d12aa10c668c6b9f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 07:35:11 +0000 Subject: [PATCH 082/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 6177 -------------------------------------------- stats_node.html | 6177 -------------------------------------------- 6 files changed, 12362 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index f34e464..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 3ff4229..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index c1d8409..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index 28b42dc..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index 4e38cc4..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 5813a95..0000000 --- a/stats_node.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 953762e724d6ad73d338de51233e5f90f8b9dbae Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 07:35:41 +0000 Subject: [PATCH 083/146] 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 | 60 +- SECURITY.md | 5 - benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 6177 +++++++++++++++++ stats_node.html | 6177 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 155 - 50 files changed, 12402 insertions(+), 4398 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 create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 11d58b2..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/max-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 d216ea9..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/max-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 397c349..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: '33 21 * * 3' - - # 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 +``` -```javascript -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -111,12 +117,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
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 f40f14b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 e6faa0e..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 `max_view_buffer_index`. -*/ -#include -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 b0f5a0e..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/max-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..f34e464 --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 5c6cc00..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import maxViewBufferIndex from '../docs/types/index'; -export = maxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9934011..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(i,r){return function(){return r||i((r={exports:{}}).exports,r),r.exports}};var f=a(function(m,x){ -function v(i,r,t){var u,n,e;for(u=i.length,n=t,e=0;e0&&(n+=r[e]*(i[e]-1))}return n}x.exports=v -});var c=f();module.exports=c; -/** @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 f54d3d9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 maximum linear index in an underlying data buffer accessible to an array view.\n*\n* @module @stdlib/ndarray-base-max-view-buffer-index\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\n\n// MODULES //\n\nvar maxViewBufferIndex = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAoBC,EAAOC,EAASC,EAAS,CACrD,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAM,OACdI,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAKL,EAAOK,CAAE,IAAM,EACnB,OAAOH,EAEHD,EAASI,CAAE,EAAI,IACnBD,GAAOH,EAASI,CAAE,GAAML,EAAOK,CAAE,EAAI,GAEvC,CACA,OAAOD,CACR,CAKAN,EAAO,QAAUC,ICfjB,IAAIO,EAAqB,IAKzB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "maxViewBufferIndex", "shape", "strides", "offset", "ndims", "idx", "i", "maxViewBufferIndex"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index c200e94..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..c1d8409 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 0c1e4d4..5c34004 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.2.0", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.3.1", - "@stdlib/utils-library-manifest": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.0" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..9faa149 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..b9757bc --- /dev/null +++ b/stats_node.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 ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From 53e9d9b2b922fc32a6ea13abff9d66c9a728efd8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 10:39:18 +0000 Subject: [PATCH 084/146] Update README.md for UMD bundle v0.2.0 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index de1557f..58d4274 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ limitations under the License. To use in Observable, ```javascript -maxViewBufferIndex = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-max-view-buffer-index@umd/browser.js' ) +maxViewBufferIndex = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-max-view-buffer-index@v0.2.0-umd/browser.js' ) ``` To vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build: @@ -66,7 +66,7 @@ var maxViewBufferIndex = require( 'path/to/vendor/umd/ndarray-base-max-view-buff To include the bundle in a webpage, ```html - + ``` If no recognized module system is present, access bundle contents via the global scope: @@ -125,7 +125,7 @@ var idx = maxViewBufferIndex( shape, strides, offset ); - + + ``` If no recognized module system is present, access bundle contents via the global scope: @@ -125,7 +130,7 @@ var idx = maxViewBufferIndex( shape, strides, offset ); - + - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index b9757bc..0000000 --- a/stats_node.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From dcc17a0166172163b6d4cf48a666e07f5f6632a6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 22 Feb 2024 03:31:55 +0000 Subject: [PATCH 088/146] 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 | 60 +- SECURITY.md | 5 - benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 4842 +++++++++++++++++ stats_node.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 155 - 50 files changed, 9732 insertions(+), 4392 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 create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 11d58b2..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/max-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 d216ea9..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/max-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 19574d1..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: '33 21 * * 3' - - # 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 +``` -```javascript -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -111,12 +117,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
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 f40f14b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 e6faa0e..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 `max_view_buffer_index`. -*/ -#include -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 b0f5a0e..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/max-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..f34e464 --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 5c6cc00..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import maxViewBufferIndex from '../docs/types/index'; -export = maxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9934011..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(i,r){return function(){return r||i((r={exports:{}}).exports,r),r.exports}};var f=a(function(m,x){ -function v(i,r,t){var u,n,e;for(u=i.length,n=t,e=0;e0&&(n+=r[e]*(i[e]-1))}return n}x.exports=v -});var c=f();module.exports=c; -/** @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 f54d3d9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 maximum linear index in an underlying data buffer accessible to an array view.\n*\n* @module @stdlib/ndarray-base-max-view-buffer-index\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\n\n// MODULES //\n\nvar maxViewBufferIndex = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAoBC,EAAOC,EAASC,EAAS,CACrD,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAM,OACdI,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAKL,EAAOK,CAAE,IAAM,EACnB,OAAOH,EAEHD,EAASI,CAAE,EAAI,IACnBD,GAAOH,EAASI,CAAE,GAAML,EAAOK,CAAE,EAAI,GAEvC,CACA,OAAOD,CACR,CAKAN,EAAO,QAAUC,ICfjB,IAAIO,EAAqB,IAKzB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "maxViewBufferIndex", "shape", "strides", "offset", "ndims", "idx", "i", "maxViewBufferIndex"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index c200e94..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..c1d8409 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 9606257..70ef57c 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.2.1", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.3.2", - "@stdlib/utils-library-manifest": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..d2dbd79 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..e98040b --- /dev/null +++ b/stats_node.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 ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From 25dd6354cab4fb5c882681b8ee7d868eba2c2f84 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 22 Feb 2024 03:54:21 +0000 Subject: [PATCH 089/146] Update README.md for UMD bundle v0.2.1 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4c08573..76cf16d 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ limitations under the License. To use in Observable, ```javascript -maxViewBufferIndex = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-max-view-buffer-index@umd/browser.js' ) +maxViewBufferIndex = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-max-view-buffer-index@v0.2.1-umd/browser.js' ) ``` To vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build: @@ -66,7 +66,7 @@ var maxViewBufferIndex = require( 'path/to/vendor/umd/ndarray-base-max-view-buff To include the bundle in a webpage, ```html - + ``` If no recognized module system is present, access bundle contents via the global scope: @@ -125,7 +125,7 @@ var idx = maxViewBufferIndex( shape, strides, offset ); - + + ``` If no recognized module system is present, access bundle contents via the global scope: @@ -125,7 +130,7 @@ var idx = maxViewBufferIndex( shape, strides, offset ); - + - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index e98040b..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a04c2cc5fec332f2e96cc77fe50385f640adb3a6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 03:46:23 +0000 Subject: [PATCH 093/146] 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 | 60 +- SECURITY.md | 5 - benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 4842 +++++++++++++++++ stats_node.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 155 - 51 files changed, 9732 insertions(+), 4394 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 create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 0fd2274..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-03-01T01:28:15.822Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 11d58b2..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/max-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 d216ea9..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/max-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 19574d1..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: '33 21 * * 3' - - # 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 +``` -```javascript -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -111,12 +117,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
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 f40f14b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 e6faa0e..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 `max_view_buffer_index`. -*/ -#include -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 b0f5a0e..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/max-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..f34e464 --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 5c6cc00..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import maxViewBufferIndex from '../docs/types/index'; -export = maxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9934011..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(i,r){return function(){return r||i((r={exports:{}}).exports,r),r.exports}};var f=a(function(m,x){ -function v(i,r,t){var u,n,e;for(u=i.length,n=t,e=0;e0&&(n+=r[e]*(i[e]-1))}return n}x.exports=v -});var c=f();module.exports=c; -/** @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 f54d3d9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 maximum linear index in an underlying data buffer accessible to an array view.\n*\n* @module @stdlib/ndarray-base-max-view-buffer-index\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\n\n// MODULES //\n\nvar maxViewBufferIndex = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAoBC,EAAOC,EAASC,EAAS,CACrD,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAM,OACdI,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAKL,EAAOK,CAAE,IAAM,EACnB,OAAOH,EAEHD,EAASI,CAAE,EAAI,IACnBD,GAAOH,EAASI,CAAE,GAAML,EAAOK,CAAE,EAAI,GAEvC,CACA,OAAOD,CACR,CAKAN,EAAO,QAAUC,ICfjB,IAAIO,EAAqB,IAKzB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "maxViewBufferIndex", "shape", "strides", "offset", "ndims", "idx", "i", "maxViewBufferIndex"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index c200e94..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..c1d8409 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 b374032..70ef57c 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.2.1", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.3.2", - "@stdlib/utils-library-manifest": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..d2dbd79 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..e98040b --- /dev/null +++ b/stats_node.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 ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From 77571900435855548e3a584b9c4a1e1516aef38c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 01:44:53 +0000 Subject: [PATCH 094/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index be5b281..b374032 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^0.3.2", - "@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-nonnegative-integer": "^0.2.1", @@ -93,4 +94,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From ddcbd0f2e9f10e303b26602ac2629f3f4db5966a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 03:55:23 +0000 Subject: [PATCH 095/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 4842 -------------------------------------------- stats_node.html | 4842 -------------------------------------------- 6 files changed, 9692 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index f34e464..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 3ff4229..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index c1d8409..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index 28b42dc..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index d2dbd79..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index e98040b..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 89798d15607c5935a00543c947b6a1c0db8c7cc2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 03:55:33 +0000 Subject: [PATCH 096/146] 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 | 60 +- SECURITY.md | 5 - benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 4842 +++++++++++++++++ stats_node.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 155 - 51 files changed, 9732 insertions(+), 4397 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 create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 f8d6767..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T01:15:50.930Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 11d58b2..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/max-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 d216ea9..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/max-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 19574d1..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: '33 21 * * 3' - - # 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 +``` -```javascript -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -111,12 +117,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
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 f40f14b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 e6faa0e..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 `max_view_buffer_index`. -*/ -#include -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 b0f5a0e..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/max-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..f34e464 --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 5c6cc00..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import maxViewBufferIndex from '../docs/types/index'; -export = maxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9934011..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(i,r){return function(){return r||i((r={exports:{}}).exports,r),r.exports}};var f=a(function(m,x){ -function v(i,r,t){var u,n,e;for(u=i.length,n=t,e=0;e0&&(n+=r[e]*(i[e]-1))}return n}x.exports=v -});var c=f();module.exports=c; -/** @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 f54d3d9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 maximum linear index in an underlying data buffer accessible to an array view.\n*\n* @module @stdlib/ndarray-base-max-view-buffer-index\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\n\n// MODULES //\n\nvar maxViewBufferIndex = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAoBC,EAAOC,EAASC,EAAS,CACrD,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAM,OACdI,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAKL,EAAOK,CAAE,IAAM,EACnB,OAAOH,EAEHD,EAASI,CAAE,EAAI,IACnBD,GAAOH,EAASI,CAAE,GAAML,EAAOK,CAAE,EAAI,GAEvC,CACA,OAAOD,CACR,CAKAN,EAAO,QAAUC,ICfjB,IAAIO,EAAqB,IAKzB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "maxViewBufferIndex", "shape", "strides", "offset", "ndims", "idx", "i", "maxViewBufferIndex"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index c200e94..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..c1d8409 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 b374032..70ef57c 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.2.1", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.3.2", - "@stdlib/utils-library-manifest": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..d2dbd79 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..e98040b --- /dev/null +++ b/stats_node.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 ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From 937167a900e9034a1ba855747bdfa27ae2d0b303 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 11 Apr 2024 21:50:39 +0000 Subject: [PATCH 097/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index be5b281..b374032 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^0.3.2", - "@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-nonnegative-integer": "^0.2.1", @@ -93,4 +94,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From f43f4f73ea18d9ba4d0d6d736d20467a84a60381 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 11 Apr 2024 23:57:58 +0000 Subject: [PATCH 098/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 4842 -------------------------------------------- stats_node.html | 4842 -------------------------------------------- 6 files changed, 9692 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index f34e464..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 3ff4229..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index c1d8409..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index 28b42dc..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index d2dbd79..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index e98040b..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 42365d67449878aed2fd2afff99b4711faf60a41 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 11 Apr 2024 23:58:16 +0000 Subject: [PATCH 099/146] 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 | 60 +- SECURITY.md | 5 - benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 4842 +++++++++++++++++ stats_node.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 155 - 50 files changed, 9732 insertions(+), 4398 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 create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 11d58b2..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/max-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 d216ea9..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/max-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 19574d1..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: '33 21 * * 3' - - # 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 +``` -```javascript -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -111,12 +117,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
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 f40f14b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 e6faa0e..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 `max_view_buffer_index`. -*/ -#include -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 b0f5a0e..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/max-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..f34e464 --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 5c6cc00..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import maxViewBufferIndex from '../docs/types/index'; -export = maxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9934011..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(i,r){return function(){return r||i((r={exports:{}}).exports,r),r.exports}};var f=a(function(m,x){ -function v(i,r,t){var u,n,e;for(u=i.length,n=t,e=0;e0&&(n+=r[e]*(i[e]-1))}return n}x.exports=v -});var c=f();module.exports=c; -/** @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 f54d3d9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 maximum linear index in an underlying data buffer accessible to an array view.\n*\n* @module @stdlib/ndarray-base-max-view-buffer-index\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\n\n// MODULES //\n\nvar maxViewBufferIndex = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAoBC,EAAOC,EAASC,EAAS,CACrD,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAM,OACdI,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAKL,EAAOK,CAAE,IAAM,EACnB,OAAOH,EAEHD,EAASI,CAAE,EAAI,IACnBD,GAAOH,EAASI,CAAE,GAAML,EAAOK,CAAE,EAAI,GAEvC,CACA,OAAOD,CACR,CAKAN,EAAO,QAAUC,ICfjB,IAAIO,EAAqB,IAKzB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "maxViewBufferIndex", "shape", "strides", "offset", "ndims", "idx", "i", "maxViewBufferIndex"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index c200e94..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..c1d8409 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 b374032..70ef57c 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.2.1", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.3.2", - "@stdlib/utils-library-manifest": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..d2dbd79 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..e98040b --- /dev/null +++ b/stats_node.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 ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From 8c8151082e4d15e73567fa7c425a938241ecb652 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 May 2024 01:45:20 +0000 Subject: [PATCH 100/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index be5b281..b374032 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^0.3.2", - "@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-nonnegative-integer": "^0.2.1", @@ -93,4 +94,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 86558c5bc1ea7efafa03422f62b305cba8b6ed43 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 May 2024 03:17:05 +0000 Subject: [PATCH 101/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 4842 -------------------------------------------- stats_node.html | 4842 -------------------------------------------- 6 files changed, 9692 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index f34e464..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 3ff4229..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index c1d8409..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index 28b42dc..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index d2dbd79..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index e98040b..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 8106a1bd3642bb680f3b634b7c4c424f85e29c62 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 May 2024 03:17:21 +0000 Subject: [PATCH 102/146] 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 | 60 +- SECURITY.md | 5 - benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 4842 +++++++++++++++++ stats_node.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 155 - 51 files changed, 9732 insertions(+), 4406 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 create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 1110d00..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-05-01T01:16:35.723Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 11d58b2..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/max-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 d216ea9..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/max-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 19574d1..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: '33 21 * * 3' - - # 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 +``` -```javascript -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -111,12 +117,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
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 f40f14b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 e6faa0e..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 `max_view_buffer_index`. -*/ -#include -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 b0f5a0e..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/max-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..f34e464 --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 5c6cc00..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import maxViewBufferIndex from '../docs/types/index'; -export = maxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9934011..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(i,r){return function(){return r||i((r={exports:{}}).exports,r),r.exports}};var f=a(function(m,x){ -function v(i,r,t){var u,n,e;for(u=i.length,n=t,e=0;e0&&(n+=r[e]*(i[e]-1))}return n}x.exports=v -});var c=f();module.exports=c; -/** @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 f54d3d9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 maximum linear index in an underlying data buffer accessible to an array view.\n*\n* @module @stdlib/ndarray-base-max-view-buffer-index\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\n\n// MODULES //\n\nvar maxViewBufferIndex = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAoBC,EAAOC,EAASC,EAAS,CACrD,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAM,OACdI,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAKL,EAAOK,CAAE,IAAM,EACnB,OAAOH,EAEHD,EAASI,CAAE,EAAI,IACnBD,GAAOH,EAASI,CAAE,GAAML,EAAOK,CAAE,EAAI,GAEvC,CACA,OAAOD,CACR,CAKAN,EAAO,QAAUC,ICfjB,IAAIO,EAAqB,IAKzB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "maxViewBufferIndex", "shape", "strides", "offset", "ndims", "idx", "i", "maxViewBufferIndex"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index c200e94..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..c1d8409 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 b374032..70ef57c 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.2.1", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.3.2", - "@stdlib/utils-library-manifest": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..d2dbd79 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..e98040b --- /dev/null +++ b/stats_node.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 ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From 3c135ff805797d46461e90c917603f86b97561ad Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jun 2024 01:56:18 +0000 Subject: [PATCH 103/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index be5b281..b374032 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^0.3.2", - "@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-nonnegative-integer": "^0.2.1", @@ -93,4 +94,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 165534155441ff6ab0df3911875626fb0ac2b7df Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jun 2024 03:21:32 +0000 Subject: [PATCH 104/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 4842 -------------------------------------------- stats_node.html | 4842 -------------------------------------------- 6 files changed, 9692 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index f34e464..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 3ff4229..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index c1d8409..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index 28b42dc..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index d2dbd79..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index e98040b..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 28590f1506410d3893bb2270825420c69fd5ffa9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jun 2024 03:21:48 +0000 Subject: [PATCH 105/146] 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 | 60 +- SECURITY.md | 5 - benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 4842 +++++++++++++++++ stats_node.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 155 - 51 files changed, 9732 insertions(+), 4406 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 create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 f440b4b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-06-01T01:28:32.905Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 11d58b2..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/max-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 d216ea9..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/max-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 19574d1..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: '33 21 * * 3' - - # 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 +``` -```javascript -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -111,12 +117,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
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 f40f14b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 e6faa0e..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 `max_view_buffer_index`. -*/ -#include -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 b0f5a0e..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/max-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..f34e464 --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 5c6cc00..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import maxViewBufferIndex from '../docs/types/index'; -export = maxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9934011..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(i,r){return function(){return r||i((r={exports:{}}).exports,r),r.exports}};var f=a(function(m,x){ -function v(i,r,t){var u,n,e;for(u=i.length,n=t,e=0;e0&&(n+=r[e]*(i[e]-1))}return n}x.exports=v -});var c=f();module.exports=c; -/** @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 f54d3d9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 maximum linear index in an underlying data buffer accessible to an array view.\n*\n* @module @stdlib/ndarray-base-max-view-buffer-index\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\n\n// MODULES //\n\nvar maxViewBufferIndex = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAoBC,EAAOC,EAASC,EAAS,CACrD,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAM,OACdI,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAKL,EAAOK,CAAE,IAAM,EACnB,OAAOH,EAEHD,EAASI,CAAE,EAAI,IACnBD,GAAOH,EAASI,CAAE,GAAML,EAAOK,CAAE,EAAI,GAEvC,CACA,OAAOD,CACR,CAKAN,EAAO,QAAUC,ICfjB,IAAIO,EAAqB,IAKzB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "maxViewBufferIndex", "shape", "strides", "offset", "ndims", "idx", "i", "maxViewBufferIndex"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index c200e94..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..c1d8409 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 b374032..70ef57c 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.2.1", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.3.2", - "@stdlib/utils-library-manifest": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..d2dbd79 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..e98040b --- /dev/null +++ b/stats_node.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 ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From f856364ae06b438b3a251a3df3b2585eb6051758 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jul 2024 01:53:58 +0000 Subject: [PATCH 106/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index be5b281..b374032 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^0.3.2", - "@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-nonnegative-integer": "^0.2.1", @@ -93,4 +94,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 342ef658f37ec022615c236833a1816ae07c8e90 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jul 2024 03:22:18 +0000 Subject: [PATCH 107/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 4842 -------------------------------------------- stats_node.html | 4842 -------------------------------------------- 6 files changed, 9692 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index f34e464..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 3ff4229..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index c1d8409..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index 28b42dc..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index d2dbd79..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index e98040b..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From f96752e80ee71988c3d9f242ca86a85195af9b80 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jul 2024 03:22:32 +0000 Subject: [PATCH 108/146] 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 | 60 +- SECURITY.md | 5 - benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 4842 +++++++++++++++++ stats_node.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 155 - 51 files changed, 9732 insertions(+), 4443 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 create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 0c5ee41..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-07-01T01:25:08.943Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 11d58b2..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/max-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 d216ea9..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/max-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 19574d1..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: '33 21 * * 3' - - # 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 +``` -```javascript -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -111,12 +117,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
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 f40f14b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 e6faa0e..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 `max_view_buffer_index`. -*/ -#include -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 b0f5a0e..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/max-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..f34e464 --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 5c6cc00..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import maxViewBufferIndex from '../docs/types/index'; -export = maxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9934011..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(i,r){return function(){return r||i((r={exports:{}}).exports,r),r.exports}};var f=a(function(m,x){ -function v(i,r,t){var u,n,e;for(u=i.length,n=t,e=0;e0&&(n+=r[e]*(i[e]-1))}return n}x.exports=v -});var c=f();module.exports=c; -/** @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 f54d3d9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 maximum linear index in an underlying data buffer accessible to an array view.\n*\n* @module @stdlib/ndarray-base-max-view-buffer-index\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\n\n// MODULES //\n\nvar maxViewBufferIndex = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAoBC,EAAOC,EAASC,EAAS,CACrD,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAM,OACdI,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAKL,EAAOK,CAAE,IAAM,EACnB,OAAOH,EAEHD,EAASI,CAAE,EAAI,IACnBD,GAAOH,EAASI,CAAE,GAAML,EAAOK,CAAE,EAAI,GAEvC,CACA,OAAOD,CACR,CAKAN,EAAO,QAAUC,ICfjB,IAAIO,EAAqB,IAKzB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "maxViewBufferIndex", "shape", "strides", "offset", "ndims", "idx", "i", "maxViewBufferIndex"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index c200e94..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..c1d8409 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 b374032..70ef57c 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.2.1", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.3.2", - "@stdlib/utils-library-manifest": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..d2dbd79 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..e98040b --- /dev/null +++ b/stats_node.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 ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From 506e743756a55900d35a4b616942eba921d0c3a3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 02:13:36 +0000 Subject: [PATCH 109/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2c1e43c..65eebcb 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^0.3.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-nonnegative-integer": "^0.2.1", @@ -93,4 +94,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 84fcf49d74f8d9d9d32f853e6b05958920549ae0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 02:34:34 +0000 Subject: [PATCH 110/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 4842 -------------------------------------------- stats_node.html | 4842 -------------------------------------------- 6 files changed, 9692 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index f34e464..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 3ff4229..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index c1d8409..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index 28b42dc..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index d2dbd79..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index e98040b..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 6b8765f8c89cb3806aa624e6baa44c30e94ceec5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 02:34:50 +0000 Subject: [PATCH 111/146] 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 | 205 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 60 +- SECURITY.md | 5 - benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 141 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 4842 +++++++++++++++++ stats_node.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 155 - 50 files changed, 9732 insertions(+), 4609 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 create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 11d58b2..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/max-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 d216ea9..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/max-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 19574d1..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: '33 21 * * 3' - - # 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 +``` -```javascript -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -111,12 +117,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
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 f40f14b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 e6faa0e..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 `max_view_buffer_index`. -*/ -#include -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 b0f5a0e..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/max-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..f34e464 --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 5c6cc00..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import maxViewBufferIndex from '../docs/types/index'; -export = maxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9934011..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(i,r){return function(){return r||i((r={exports:{}}).exports,r),r.exports}};var f=a(function(m,x){ -function v(i,r,t){var u,n,e;for(u=i.length,n=t,e=0;e0&&(n+=r[e]*(i[e]-1))}return n}x.exports=v -});var c=f();module.exports=c; -/** @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 f54d3d9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 maximum linear index in an underlying data buffer accessible to an array view.\n*\n* @module @stdlib/ndarray-base-max-view-buffer-index\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\n\n// MODULES //\n\nvar maxViewBufferIndex = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAoBC,EAAOC,EAASC,EAAS,CACrD,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAM,OACdI,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAKL,EAAOK,CAAE,IAAM,EACnB,OAAOH,EAEHD,EAASI,CAAE,EAAI,IACnBD,GAAOH,EAASI,CAAE,GAAML,EAAOK,CAAE,EAAI,GAEvC,CACA,OAAOD,CACR,CAKAN,EAAO,QAAUC,ICfjB,IAAIO,EAAqB,IAKzB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "maxViewBufferIndex", "shape", "strides", "offset", "ndims", "idx", "i", "maxViewBufferIndex"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index c200e94..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..c1d8409 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 65eebcb..ace1596 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.2.2", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.3.2", - "@stdlib/utils-library-manifest": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..d2dbd79 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..e98040b --- /dev/null +++ b/stats_node.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 ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From f4eee7069c004a9bc0dfa018bd4e4d7b87dc3e3a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 02:50:41 +0000 Subject: [PATCH 112/146] Update README.md for UMD bundle v0.2.2 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9432fe8..7aa4514 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ limitations under the License. To use in Observable, ```javascript -maxViewBufferIndex = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-max-view-buffer-index@umd/browser.js' ) +maxViewBufferIndex = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-max-view-buffer-index@v0.2.2-umd/browser.js' ) ``` To vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build: @@ -66,7 +66,7 @@ var maxViewBufferIndex = require( 'path/to/vendor/umd/ndarray-base-max-view-buff To include the bundle in a webpage, ```html - + ``` If no recognized module system is present, access bundle contents via the global scope: @@ -125,7 +125,7 @@ var idx = maxViewBufferIndex( shape, strides, offset ); - + + ``` If no recognized module system is present, access bundle contents via the global scope: @@ -125,7 +130,7 @@ var idx = maxViewBufferIndex( shape, strides, offset ); - + - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index e98040b..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 8d945a3cdf6a31a4c6d38f4bd5485f9f381d7797 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 03:48:10 +0000 Subject: [PATCH 116/146] 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 | 60 +- SECURITY.md | 5 - benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 138 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 4842 +++++++++++++++++ stats_node.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 155 - 51 files changed, 9732 insertions(+), 4572 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 create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 caaede0..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-01T01:29:35.892Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 11d58b2..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/max-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 d216ea9..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/max-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 19574d1..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: '33 21 * * 3' - - # 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 +``` -```javascript -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -111,12 +117,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
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 f40f14b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 077163b..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 -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 b0f5a0e..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/max-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..f34e464 --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 5c6cc00..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import maxViewBufferIndex from '../docs/types/index'; -export = maxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9934011..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(i,r){return function(){return r||i((r={exports:{}}).exports,r),r.exports}};var f=a(function(m,x){ -function v(i,r,t){var u,n,e;for(u=i.length,n=t,e=0;e0&&(n+=r[e]*(i[e]-1))}return n}x.exports=v -});var c=f();module.exports=c; -/** @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 f54d3d9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 maximum linear index in an underlying data buffer accessible to an array view.\n*\n* @module @stdlib/ndarray-base-max-view-buffer-index\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\n\n// MODULES //\n\nvar maxViewBufferIndex = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAoBC,EAAOC,EAASC,EAAS,CACrD,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAM,OACdI,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAKL,EAAOK,CAAE,IAAM,EACnB,OAAOH,EAEHD,EAASI,CAAE,EAAI,IACnBD,GAAOH,EAASI,CAAE,GAAML,EAAOK,CAAE,EAAI,GAEvC,CACA,OAAOD,CACR,CAKAN,EAAO,QAAUC,ICfjB,IAAIO,EAAqB,IAKzB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "maxViewBufferIndex", "shape", "strides", "offset", "ndims", "idx", "i", "maxViewBufferIndex"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index c200e94..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..c1d8409 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 12690b5..ace1596 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.2.2", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.3.2", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..d2dbd79 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..e98040b --- /dev/null +++ b/stats_node.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 ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From 2d15d6c94dabe8bb3baad84b7f524e2a99756e43 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 16:37:42 +0000 Subject: [PATCH 117/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e57cfc0..12690b5 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^0.3.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-nonnegative-integer": "^0.2.2", @@ -93,4 +94,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 8768b6324ebe4a7b67c282be3e92146cff2aa12e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 17:42:32 +0000 Subject: [PATCH 118/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 4842 -------------------------------------------- stats_node.html | 4842 -------------------------------------------- 6 files changed, 9692 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index f34e464..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 3ff4229..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index c1d8409..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index 28b42dc..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index d2dbd79..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index e98040b..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From bc692d8984ed1b22d5baaddc1a70d13c08922701 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 17:42:46 +0000 Subject: [PATCH 119/146] 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 | 239 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 60 +- SECURITY.md | 5 - benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 138 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 4842 +++++++++++++++++ stats_node.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 155 - 51 files changed, 9732 insertions(+), 4643 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 create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 8d11274..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-03T16:16:05.463Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 11d58b2..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/max-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 d216ea9..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/max-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 19574d1..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: '33 21 * * 3' - - # 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 +``` -```javascript -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -111,12 +117,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
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 f40f14b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 077163b..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 -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 b0f5a0e..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/max-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..f34e464 --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 5c6cc00..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import maxViewBufferIndex from '../docs/types/index'; -export = maxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9934011..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(i,r){return function(){return r||i((r={exports:{}}).exports,r),r.exports}};var f=a(function(m,x){ -function v(i,r,t){var u,n,e;for(u=i.length,n=t,e=0;e0&&(n+=r[e]*(i[e]-1))}return n}x.exports=v -});var c=f();module.exports=c; -/** @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 f54d3d9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 maximum linear index in an underlying data buffer accessible to an array view.\n*\n* @module @stdlib/ndarray-base-max-view-buffer-index\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\n\n// MODULES //\n\nvar maxViewBufferIndex = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAoBC,EAAOC,EAASC,EAAS,CACrD,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAM,OACdI,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAKL,EAAOK,CAAE,IAAM,EACnB,OAAOH,EAEHD,EAASI,CAAE,EAAI,IACnBD,GAAOH,EAASI,CAAE,GAAML,EAAOK,CAAE,EAAI,GAEvC,CACA,OAAOD,CACR,CAKAN,EAAO,QAAUC,ICfjB,IAAIO,EAAqB,IAKzB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "maxViewBufferIndex", "shape", "strides", "offset", "ndims", "idx", "i", "maxViewBufferIndex"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index c200e94..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..c1d8409 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 12690b5..ace1596 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.2.2", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.3.2", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..d2dbd79 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..e98040b --- /dev/null +++ b/stats_node.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 ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From eb969a1366126c6ef81cbc57f4b787ec3db94cde Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 02:03:25 +0000 Subject: [PATCH 120/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 44d496b..8d3b489 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^0.4.1", - "@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-nonnegative-integer": "^0.2.2", @@ -93,4 +94,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 921402259bda46af0e6f5249f4883d791884d17d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 03:45:32 +0000 Subject: [PATCH 121/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 4842 -------------------------------------------- stats_node.html | 4842 -------------------------------------------- 6 files changed, 9692 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index f34e464..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 3ff4229..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index c1d8409..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index 28b42dc..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index d2dbd79..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index e98040b..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 41bf5b0f8b3948f299d25a3bb28096671a00462a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 03:45:51 +0000 Subject: [PATCH 122/146] 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 | 238 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 60 +- SECURITY.md | 5 - benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 138 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 4842 +++++++++++++++++ stats_node.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 155 - 51 files changed, 9732 insertions(+), 4642 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 create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js delete mode 100644 include/stdlib/ndarray/base/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 c83662e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-09-01T01:36:31.022Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 11d58b2..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/max-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 d216ea9..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/max-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 19574d1..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: '33 21 * * 3' - - # 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 +``` -```javascript -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -111,12 +117,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
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 f40f14b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 077163b..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 -#include -#include -#include -#include -#include -#include "stdlib/ndarray/base/max_view_buffer_index.h" - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 b0f5a0e..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/max-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..f34e464 --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 5c6cc00..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import maxViewBufferIndex from '../docs/types/index'; -export = maxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9934011..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(i,r){return function(){return r||i((r={exports:{}}).exports,r),r.exports}};var f=a(function(m,x){ -function v(i,r,t){var u,n,e;for(u=i.length,n=t,e=0;e0&&(n+=r[e]*(i[e]-1))}return n}x.exports=v -});var c=f();module.exports=c; -/** @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 f54d3d9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 maximum linear index in an underlying data buffer accessible to an array view.\n*\n* @module @stdlib/ndarray-base-max-view-buffer-index\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\n\n// MODULES //\n\nvar maxViewBufferIndex = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAoBC,EAAOC,EAASC,EAAS,CACrD,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAM,OACdI,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAKL,EAAOK,CAAE,IAAM,EACnB,OAAOH,EAEHD,EAASI,CAAE,EAAI,IACnBD,GAAOH,EAASI,CAAE,GAAML,EAAOK,CAAE,EAAI,GAEvC,CACA,OAAOD,CACR,CAKAN,EAAO,QAAUC,ICfjB,IAAIO,EAAqB,IAKzB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "maxViewBufferIndex", "shape", "strides", "offset", "ndims", "idx", "i", "maxViewBufferIndex"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index c200e94..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index b7de4a6..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..c1d8409 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 8d3b489..ace1596 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.2.2", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.4.1", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^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", @@ -89,9 +32,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 3044742..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..d2dbd79 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..e98040b --- /dev/null +++ b/stats_node.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 ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From 97f51637156c4cb51b19cfa2723915f99f110189 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 12 Sep 2024 05:35:20 +0000 Subject: [PATCH 123/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 44d496b..8d3b489 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^0.4.1", - "@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-nonnegative-integer": "^0.2.2", @@ -93,4 +94,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 9ac218b57510474c3c7f54cc3035a82b8977041e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 12 Sep 2024 05:35:46 +0000 Subject: [PATCH 124/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 4842 -------------------------------------------- stats_node.html | 4842 -------------------------------------------- 6 files changed, 9692 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index f34e464..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 3ff4229..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index c1d8409..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index 28b42dc..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index d2dbd79..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index e98040b..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 80300e3623d06dfde32dcb16a046d5124b6025a2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 12 Sep 2024 05:36:07 +0000 Subject: [PATCH 125/146] 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 | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 239 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 162 +- SECURITY.md | 5 - benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 138 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 42 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 4842 +++++++++++++++++ stats_node.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 155 - 52 files changed, 9732 insertions(+), 4932 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 create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts 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/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 11d58b2..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/max-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 d216ea9..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/max-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 19574d1..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: '33 21 * * 3' - - # 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 +``` -```javascript -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -111,12 +117,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
@@ -157,109 +173,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/max_view_buffer_index.h" -``` - -#### stdlib_ndarray_max_view_buffer_index( ndims, \*shape, \*strides, offset ) - -Computes the maximum linear index (in bytes) in an underlying data buffer accessible to an array view. - -```c -#include - -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; - -int64_t idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -// 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. - -```c -int64_t stdlib_ndarray_max_view_buffer_index( const int64_t ndims, const int64_t *shape, const int64_t *strides, const int64_t offset ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include -#include -#include - -int main( void ) { - // Specify the number of dimensions: - const int64_t ndims = 2; - - // Define an array shape: - const int64_t shape[] = { 10, 10 }; - - // Define array strides: - const int64_t strides[] = { -2, 5 }; - - // Define an offset: - const int64_t offset = 100; - - // Compute the maximum accessible index: - int64_t idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - - // Print the results: - printf( "idx: %"PRId64"\n", idx ); -} -``` - -
- - - -
- 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 f40f14b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 04ac010..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/max_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 b0f5a0e..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/max-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..f34e464 --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 5c6cc00..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import maxViewBufferIndex from '../docs/types/index'; -export = maxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9934011..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(i,r){return function(){return r||i((r={exports:{}}).exports,r),r.exports}};var f=a(function(m,x){ -function v(i,r,t){var u,n,e;for(u=i.length,n=t,e=0;e0&&(n+=r[e]*(i[e]-1))}return n}x.exports=v -});var c=f();module.exports=c; -/** @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 f54d3d9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 maximum linear index in an underlying data buffer accessible to an array view.\n*\n* @module @stdlib/ndarray-base-max-view-buffer-index\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\n\n// MODULES //\n\nvar maxViewBufferIndex = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAoBC,EAAOC,EAASC,EAAS,CACrD,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAM,OACdI,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAKL,EAAOK,CAAE,IAAM,EACnB,OAAOH,EAEHD,EAASI,CAAE,EAAI,IACnBD,GAAOH,EAASI,CAAE,GAAML,EAAOK,CAAE,EAAI,GAEvC,CACA,OAAOD,CACR,CAKAN,EAAO,QAAUC,ICfjB,IAAIO,EAAqB,IAKzB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "maxViewBufferIndex", "shape", "strides", "offset", "ndims", "idx", "i", "maxViewBufferIndex"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index c200e94..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index 6aed70d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2024 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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 ee081f0..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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/max_view_buffer_index.h" -#include -#include -#include - -int main( void ) { - // Specify the number of dimensions: - const int64_t ndims = 2; - - // Define an array shape: - const int64_t shape[] = { 10, 10 }; - - // Define array strides: - const int64_t strides[] = { -2, 5 }; - - // Define an offset: - const int64_t offset = 100; - - // Compute the maximum accessible index: - int64_t idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - - // Print the results: - printf( "idx: %"PRId64"\n", idx ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index 6a35bfe..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( const int64_t ndims, const int64_t *shape, const int64_t *strides, const int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..c1d8409 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 8d3b489..ace1596 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.2.2", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.4.1", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^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", @@ -89,9 +32,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 c63eb0f..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( const int64_t ndims, const int64_t *shape, const int64_t *strides, const int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..d2dbd79 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..e98040b --- /dev/null +++ b/stats_node.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 ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From 7f646bd4c6f7df927da28d2542785e039f600b0d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 02:08:46 +0000 Subject: [PATCH 126/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 44d496b..8d3b489 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^0.4.1", - "@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-nonnegative-integer": "^0.2.2", @@ -93,4 +94,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 2d7ec637113d35e0cfbeaebfb856a604d384d0aa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 03:40:22 +0000 Subject: [PATCH 127/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 4842 -------------------------------------------- stats_node.html | 4842 -------------------------------------------- 6 files changed, 9692 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index f34e464..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 3ff4229..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index c1d8409..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index 28b42dc..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index d2dbd79..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index e98040b..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5e6d2f1926e469bd101fe59c8811e6a87b9c3067 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 03:40:37 +0000 Subject: [PATCH 128/146] 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 | 239 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 162 +- SECURITY.md | 5 - benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 138 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 42 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 4842 +++++++++++++++++ stats_node.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 155 - 53 files changed, 9732 insertions(+), 4933 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 create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts 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/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 f7ebe13..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-10-01T01:42:57.456Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 11d58b2..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/max-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 d216ea9..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/max-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 19574d1..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: '33 21 * * 3' - - # 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 +``` -```javascript -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -111,12 +117,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
@@ -157,109 +173,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/max_view_buffer_index.h" -``` - -#### stdlib_ndarray_max_view_buffer_index( ndims, \*shape, \*strides, offset ) - -Computes the maximum linear index (in bytes) in an underlying data buffer accessible to an array view. - -```c -#include - -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; - -int64_t idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -// 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. - -```c -int64_t stdlib_ndarray_max_view_buffer_index( const int64_t ndims, const int64_t *shape, const int64_t *strides, const int64_t offset ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include -#include -#include - -int main( void ) { - // Specify the number of dimensions: - const int64_t ndims = 2; - - // Define an array shape: - const int64_t shape[] = { 10, 10 }; - - // Define array strides: - const int64_t strides[] = { -2, 5 }; - - // Define an offset: - const int64_t offset = 100; - - // Compute the maximum accessible index: - int64_t idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - - // Print the results: - printf( "idx: %"PRId64"\n", idx ); -} -``` - -
- - - -
- 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 f40f14b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 04ac010..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/max_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 b0f5a0e..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/max-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..f34e464 --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 5c6cc00..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import maxViewBufferIndex from '../docs/types/index'; -export = maxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9934011..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(i,r){return function(){return r||i((r={exports:{}}).exports,r),r.exports}};var f=a(function(m,x){ -function v(i,r,t){var u,n,e;for(u=i.length,n=t,e=0;e0&&(n+=r[e]*(i[e]-1))}return n}x.exports=v -});var c=f();module.exports=c; -/** @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 f54d3d9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 maximum linear index in an underlying data buffer accessible to an array view.\n*\n* @module @stdlib/ndarray-base-max-view-buffer-index\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\n\n// MODULES //\n\nvar maxViewBufferIndex = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAoBC,EAAOC,EAASC,EAAS,CACrD,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAM,OACdI,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAKL,EAAOK,CAAE,IAAM,EACnB,OAAOH,EAEHD,EAASI,CAAE,EAAI,IACnBD,GAAOH,EAASI,CAAE,GAAML,EAAOK,CAAE,EAAI,GAEvC,CACA,OAAOD,CACR,CAKAN,EAAO,QAAUC,ICfjB,IAAIO,EAAqB,IAKzB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "maxViewBufferIndex", "shape", "strides", "offset", "ndims", "idx", "i", "maxViewBufferIndex"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index c200e94..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index 6aed70d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2024 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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 ee081f0..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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/max_view_buffer_index.h" -#include -#include -#include - -int main( void ) { - // Specify the number of dimensions: - const int64_t ndims = 2; - - // Define an array shape: - const int64_t shape[] = { 10, 10 }; - - // Define array strides: - const int64_t strides[] = { -2, 5 }; - - // Define an offset: - const int64_t offset = 100; - - // Compute the maximum accessible index: - int64_t idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - - // Print the results: - printf( "idx: %"PRId64"\n", idx ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index 6a35bfe..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( const int64_t ndims, const int64_t *shape, const int64_t *strides, const int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..c1d8409 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 8d3b489..ace1596 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.2.2", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.4.1", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^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", @@ -89,9 +32,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 c63eb0f..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( const int64_t ndims, const int64_t *shape, const int64_t *strides, const int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..d2dbd79 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..e98040b --- /dev/null +++ b/stats_node.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 ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From 31c8a197cb35d117989a40f1ab28656a0bf674b4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 02:05:37 +0000 Subject: [PATCH 129/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 44d496b..8d3b489 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^0.4.1", - "@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-nonnegative-integer": "^0.2.2", @@ -93,4 +94,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 0d076a4be71ad9dec87d5eadbb4930804c573660 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 03:36:10 +0000 Subject: [PATCH 130/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 4842 -------------------------------------------- stats_node.html | 4842 -------------------------------------------- 6 files changed, 9692 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index f34e464..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 3ff4229..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index c1d8409..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index 28b42dc..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index d2dbd79..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index e98040b..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ee8301fbb76f27be0a57f3d176817eee96d5a0eb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 03:36:22 +0000 Subject: [PATCH 131/146] 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 | 239 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 162 +- SECURITY.md | 5 - benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 138 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 42 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 4842 +++++++++++++++++ stats_node.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 155 - 53 files changed, 9732 insertions(+), 4933 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 create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts 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/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 72a3fb2..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-11-01T01:40:10.123Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 11d58b2..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/max-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 d216ea9..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/max-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 19574d1..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: '33 21 * * 3' - - # 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 +``` -```javascript -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -111,12 +117,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
@@ -157,109 +173,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/max_view_buffer_index.h" -``` - -#### stdlib_ndarray_max_view_buffer_index( ndims, \*shape, \*strides, offset ) - -Computes the maximum linear index (in bytes) in an underlying data buffer accessible to an array view. - -```c -#include - -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; - -int64_t idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -// 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. - -```c -int64_t stdlib_ndarray_max_view_buffer_index( const int64_t ndims, const int64_t *shape, const int64_t *strides, const int64_t offset ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include -#include -#include - -int main( void ) { - // Specify the number of dimensions: - const int64_t ndims = 2; - - // Define an array shape: - const int64_t shape[] = { 10, 10 }; - - // Define array strides: - const int64_t strides[] = { -2, 5 }; - - // Define an offset: - const int64_t offset = 100; - - // Compute the maximum accessible index: - int64_t idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - - // Print the results: - printf( "idx: %"PRId64"\n", idx ); -} -``` - -
- - - -
- 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 f40f14b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 04ac010..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/max_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 b0f5a0e..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/max-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..f34e464 --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 5c6cc00..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import maxViewBufferIndex from '../docs/types/index'; -export = maxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9934011..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(i,r){return function(){return r||i((r={exports:{}}).exports,r),r.exports}};var f=a(function(m,x){ -function v(i,r,t){var u,n,e;for(u=i.length,n=t,e=0;e0&&(n+=r[e]*(i[e]-1))}return n}x.exports=v -});var c=f();module.exports=c; -/** @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 f54d3d9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 maximum linear index in an underlying data buffer accessible to an array view.\n*\n* @module @stdlib/ndarray-base-max-view-buffer-index\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\n\n// MODULES //\n\nvar maxViewBufferIndex = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAoBC,EAAOC,EAASC,EAAS,CACrD,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAM,OACdI,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAKL,EAAOK,CAAE,IAAM,EACnB,OAAOH,EAEHD,EAASI,CAAE,EAAI,IACnBD,GAAOH,EAASI,CAAE,GAAML,EAAOK,CAAE,EAAI,GAEvC,CACA,OAAOD,CACR,CAKAN,EAAO,QAAUC,ICfjB,IAAIO,EAAqB,IAKzB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "maxViewBufferIndex", "shape", "strides", "offset", "ndims", "idx", "i", "maxViewBufferIndex"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index c200e94..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index 6aed70d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2024 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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 ee081f0..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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/max_view_buffer_index.h" -#include -#include -#include - -int main( void ) { - // Specify the number of dimensions: - const int64_t ndims = 2; - - // Define an array shape: - const int64_t shape[] = { 10, 10 }; - - // Define array strides: - const int64_t strides[] = { -2, 5 }; - - // Define an offset: - const int64_t offset = 100; - - // Compute the maximum accessible index: - int64_t idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - - // Print the results: - printf( "idx: %"PRId64"\n", idx ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index 6a35bfe..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( const int64_t ndims, const int64_t *shape, const int64_t *strides, const int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..c1d8409 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 8d3b489..ace1596 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.2.2", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.4.1", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^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", @@ -89,9 +32,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 c63eb0f..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( const int64_t ndims, const int64_t *shape, const int64_t *strides, const int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..d2dbd79 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..e98040b --- /dev/null +++ b/stats_node.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 ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From 2d307c7e2807a135b381de02d4ca4fd80433236f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 02:12:09 +0000 Subject: [PATCH 132/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bbf0038..34a2595 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^0.4.3", - "@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-nonnegative-integer": "^0.2.2", @@ -93,4 +94,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From e044fc3bef15d2a2692548e6f1b8a2d4f3f7c33b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 03:45:00 +0000 Subject: [PATCH 133/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 4842 -------------------------------------------- stats_node.html | 4842 -------------------------------------------- 6 files changed, 9692 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index f34e464..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 3ff4229..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index c1d8409..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index 28b42dc..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index d2dbd79..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index e98040b..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b573bcda7d6e569dbb8f4338fa102edc6fcb5497 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 03:45:21 +0000 Subject: [PATCH 134/146] 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 | 239 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 162 +- SECURITY.md | 5 - benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 138 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 42 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 4842 +++++++++++++++++ stats_node.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 155 - 54 files changed, 9732 insertions(+), 5038 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 create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts 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/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.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 c0a5155..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-01T01:46:40.176Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 11d58b2..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/max-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 d216ea9..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/max-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 19574d1..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: '33 21 * * 3' - - # 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 +``` -```javascript -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -111,12 +117,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
@@ -157,109 +173,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/max_view_buffer_index.h" -``` - -#### stdlib_ndarray_max_view_buffer_index( ndims, \*shape, \*strides, offset ) - -Computes the maximum linear index (in bytes) in an underlying data buffer accessible to an array view. - -```c -#include - -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; - -int64_t idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -// 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. - -```c -int64_t stdlib_ndarray_max_view_buffer_index( const int64_t ndims, const int64_t *shape, const int64_t *strides, const int64_t offset ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include -#include -#include - -int main( void ) { - // Specify the number of dimensions: - const int64_t ndims = 2; - - // Define an array shape: - const int64_t shape[] = { 10, 10 }; - - // Define array strides: - const int64_t strides[] = { -2, 5 }; - - // Define an offset: - const int64_t offset = 100; - - // Compute the maximum accessible index: - int64_t idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - - // Print the results: - printf( "idx: %"PRId64"\n", idx ); -} -``` - -
- - - -
- 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 f40f14b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 04ac010..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/max_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 b0f5a0e..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/max-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..f34e464 --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 5c6cc00..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import maxViewBufferIndex from '../docs/types/index'; -export = maxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9934011..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(i,r){return function(){return r||i((r={exports:{}}).exports,r),r.exports}};var f=a(function(m,x){ -function v(i,r,t){var u,n,e;for(u=i.length,n=t,e=0;e0&&(n+=r[e]*(i[e]-1))}return n}x.exports=v -});var c=f();module.exports=c; -/** @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 f54d3d9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 maximum linear index in an underlying data buffer accessible to an array view.\n*\n* @module @stdlib/ndarray-base-max-view-buffer-index\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\n\n// MODULES //\n\nvar maxViewBufferIndex = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAoBC,EAAOC,EAASC,EAAS,CACrD,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAM,OACdI,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAKL,EAAOK,CAAE,IAAM,EACnB,OAAOH,EAEHD,EAASI,CAAE,EAAI,IACnBD,GAAOH,EAASI,CAAE,GAAML,EAAOK,CAAE,EAAI,GAEvC,CACA,OAAOD,CACR,CAKAN,EAAO,QAAUC,ICfjB,IAAIO,EAAqB,IAKzB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "maxViewBufferIndex", "shape", "strides", "offset", "ndims", "idx", "i", "maxViewBufferIndex"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index c200e94..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index 6aed70d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2024 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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 ee081f0..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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/max_view_buffer_index.h" -#include -#include -#include - -int main( void ) { - // Specify the number of dimensions: - const int64_t ndims = 2; - - // Define an array shape: - const int64_t shape[] = { 10, 10 }; - - // Define array strides: - const int64_t strides[] = { -2, 5 }; - - // Define an offset: - const int64_t offset = 100; - - // Compute the maximum accessible index: - int64_t idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - - // Print the results: - printf( "idx: %"PRId64"\n", idx ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index 6a35bfe..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( const int64_t ndims, const int64_t *shape, const int64_t *strides, const int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..c1d8409 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 34a2595..ace1596 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.2.2", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.4.3", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^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", @@ -89,9 +32,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 c63eb0f..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( const int64_t ndims, const int64_t *shape, const int64_t *strides, const int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..d2dbd79 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..e98040b --- /dev/null +++ b/stats_node.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 ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From db57cc2fa6964dceb935249366a11112edcd265b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 31 Mar 2025 00:37:44 +0000 Subject: [PATCH 135/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bbf0038..34a2595 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^0.4.3", - "@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-nonnegative-integer": "^0.2.2", @@ -93,4 +94,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From bfc327f01847ed47687f2ceb4be20b7d767e8652 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 31 Mar 2025 00:39:15 +0000 Subject: [PATCH 136/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 4842 -------------------------------------------- stats_node.html | 4842 -------------------------------------------- 6 files changed, 9692 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index f34e464..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 3ff4229..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index c1d8409..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index 28b42dc..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index d2dbd79..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index e98040b..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 346bacc81c6455a86d1388591bfb61487b7f9659 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 31 Mar 2025 00:39:39 +0000 Subject: [PATCH 137/146] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 239 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 162 +- SECURITY.md | 5 - benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 138 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 42 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 4842 +++++++++++++++++ stats_node.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 155 - 54 files changed, 9732 insertions(+), 5041 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 create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts 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/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index a2a40cd..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-03-31T00:36:44.359Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 9b2d21c..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/max-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 d216ea9..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/max-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 19574d1..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: '33 21 * * 3' - - # 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 +``` -```javascript -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -111,12 +117,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
@@ -157,109 +173,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/max_view_buffer_index.h" -``` - -#### stdlib_ndarray_max_view_buffer_index( ndims, \*shape, \*strides, offset ) - -Computes the maximum linear index (in bytes) in an underlying data buffer accessible to an array view. - -```c -#include - -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; - -int64_t idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -// 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. - -```c -int64_t stdlib_ndarray_max_view_buffer_index( const int64_t ndims, const int64_t *shape, const int64_t *strides, const int64_t offset ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include -#include -#include - -int main( void ) { - // Specify the number of dimensions: - const int64_t ndims = 2; - - // Define an array shape: - const int64_t shape[] = { 10, 10 }; - - // Define array strides: - const int64_t strides[] = { -2, 5 }; - - // Define an offset: - const int64_t offset = 100; - - // Compute the maximum accessible index: - int64_t idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - - // Print the results: - printf( "idx: %"PRId64"\n", idx ); -} -``` - -
- - - -
- 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 f40f14b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 04ac010..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/max_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 b0f5a0e..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/max-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..c0ce7dc --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 5c6cc00..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import maxViewBufferIndex from '../docs/types/index'; -export = maxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9934011..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(i,r){return function(){return r||i((r={exports:{}}).exports,r),r.exports}};var f=a(function(m,x){ -function v(i,r,t){var u,n,e;for(u=i.length,n=t,e=0;e0&&(n+=r[e]*(i[e]-1))}return n}x.exports=v -});var c=f();module.exports=c; -/** @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 f54d3d9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 maximum linear index in an underlying data buffer accessible to an array view.\n*\n* @module @stdlib/ndarray-base-max-view-buffer-index\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\n\n// MODULES //\n\nvar maxViewBufferIndex = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAoBC,EAAOC,EAASC,EAAS,CACrD,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAM,OACdI,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAKL,EAAOK,CAAE,IAAM,EACnB,OAAOH,EAEHD,EAASI,CAAE,EAAI,IACnBD,GAAOH,EAASI,CAAE,GAAML,EAAOK,CAAE,EAAI,GAEvC,CACA,OAAOD,CACR,CAKAN,EAAO,QAAUC,ICfjB,IAAIO,EAAqB,IAKzB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "maxViewBufferIndex", "shape", "strides", "offset", "ndims", "idx", "i", "maxViewBufferIndex"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index c200e94..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index 6aed70d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2024 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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 ee081f0..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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/max_view_buffer_index.h" -#include -#include -#include - -int main( void ) { - // Specify the number of dimensions: - const int64_t ndims = 2; - - // Define an array shape: - const int64_t shape[] = { 10, 10 }; - - // Define array strides: - const int64_t strides[] = { -2, 5 }; - - // Define an offset: - const int64_t offset = 100; - - // Compute the maximum accessible index: - int64_t idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - - // Print the results: - printf( "idx: %"PRId64"\n", idx ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index 6a35bfe..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( const int64_t ndims, const int64_t *shape, const int64_t *strides, const int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..dc92a2f --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 34a2595..ace1596 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.2.2", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.4.3", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^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", @@ -89,9 +32,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 c63eb0f..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( const int64_t ndims, const int64_t *shape, const int64_t *strides, const int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..d2dbd79 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..e98040b --- /dev/null +++ b/stats_node.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 ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From 428a625ce910a7bed973ca1973b212122aff2f15 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 19 May 2025 00:34:40 +0000 Subject: [PATCH 138/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bbf0038..34a2595 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^0.4.3", - "@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-nonnegative-integer": "^0.2.2", @@ -93,4 +94,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From ff10975a284bef87ed61dbf711dd9bee7c6025e2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 19 May 2025 00:35:41 +0000 Subject: [PATCH 139/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 4842 -------------------------------------------- stats_node.html | 4842 -------------------------------------------- 6 files changed, 9692 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index c0ce7dc..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 3ff4229..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index dc92a2f..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index 28b42dc..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index d2dbd79..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index e98040b..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ce910dd6c97f301eb75c5a2adef46c8fe22cef06 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 19 May 2025 00:35:57 +0000 Subject: [PATCH 140/146] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 239 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 162 +- SECURITY.md | 5 - benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 138 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 42 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 4842 +++++++++++++++++ stats_node.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 155 - 54 files changed, 9732 insertions(+), 5041 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 create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts 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/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index da9273d..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-05-19T00:34:16.319Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 9b2d21c..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/max-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 d216ea9..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/max-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 19574d1..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: '33 21 * * 3' - - # 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 +``` -```javascript -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -111,12 +117,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
@@ -157,109 +173,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/max_view_buffer_index.h" -``` - -#### stdlib_ndarray_max_view_buffer_index( ndims, \*shape, \*strides, offset ) - -Computes the maximum linear index (in bytes) in an underlying data buffer accessible to an array view. - -```c -#include - -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; - -int64_t idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -// 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. - -```c -int64_t stdlib_ndarray_max_view_buffer_index( const int64_t ndims, const int64_t *shape, const int64_t *strides, const int64_t offset ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include -#include -#include - -int main( void ) { - // Specify the number of dimensions: - const int64_t ndims = 2; - - // Define an array shape: - const int64_t shape[] = { 10, 10 }; - - // Define array strides: - const int64_t strides[] = { -2, 5 }; - - // Define an offset: - const int64_t offset = 100; - - // Compute the maximum accessible index: - int64_t idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - - // Print the results: - printf( "idx: %"PRId64"\n", idx ); -} -``` - -
- - - -
- 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 f40f14b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 04ac010..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/max_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 b0f5a0e..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/max-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..c0ce7dc --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 5c6cc00..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import maxViewBufferIndex from '../docs/types/index'; -export = maxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9934011..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(i,r){return function(){return r||i((r={exports:{}}).exports,r),r.exports}};var f=a(function(m,x){ -function v(i,r,t){var u,n,e;for(u=i.length,n=t,e=0;e0&&(n+=r[e]*(i[e]-1))}return n}x.exports=v -});var c=f();module.exports=c; -/** @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 f54d3d9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 maximum linear index in an underlying data buffer accessible to an array view.\n*\n* @module @stdlib/ndarray-base-max-view-buffer-index\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\n\n// MODULES //\n\nvar maxViewBufferIndex = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAoBC,EAAOC,EAASC,EAAS,CACrD,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAM,OACdI,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAKL,EAAOK,CAAE,IAAM,EACnB,OAAOH,EAEHD,EAASI,CAAE,EAAI,IACnBD,GAAOH,EAASI,CAAE,GAAML,EAAOK,CAAE,EAAI,GAEvC,CACA,OAAOD,CACR,CAKAN,EAAO,QAAUC,ICfjB,IAAIO,EAAqB,IAKzB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "maxViewBufferIndex", "shape", "strides", "offset", "ndims", "idx", "i", "maxViewBufferIndex"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index c200e94..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index 6aed70d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2024 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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 ee081f0..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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/max_view_buffer_index.h" -#include -#include -#include - -int main( void ) { - // Specify the number of dimensions: - const int64_t ndims = 2; - - // Define an array shape: - const int64_t shape[] = { 10, 10 }; - - // Define array strides: - const int64_t strides[] = { -2, 5 }; - - // Define an offset: - const int64_t offset = 100; - - // Compute the maximum accessible index: - int64_t idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - - // Print the results: - printf( "idx: %"PRId64"\n", idx ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index 6a35bfe..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( const int64_t ndims, const int64_t *shape, const int64_t *strides, const int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..dc92a2f --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 34a2595..ace1596 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.2.2", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.4.3", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^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", @@ -89,9 +32,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 c63eb0f..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( const int64_t ndims, const int64_t *shape, const int64_t *strides, const int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..d2dbd79 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..e98040b --- /dev/null +++ b/stats_node.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 ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From 4862ba32c28a9785e8ec9ea7c01837f4171fd02e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 26 May 2025 01:05:39 +0000 Subject: [PATCH 141/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bbf0038..34a2595 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^0.4.3", - "@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-nonnegative-integer": "^0.2.2", @@ -93,4 +94,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 440598278051d33d753962ad48d0e6e13770e7f4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 26 May 2025 01:12:59 +0000 Subject: [PATCH 142/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 4842 -------------------------------------------- stats_node.html | 4842 -------------------------------------------- 6 files changed, 9692 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index c0ce7dc..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 3ff4229..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index dc92a2f..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index 28b42dc..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index d2dbd79..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index e98040b..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b00c42fa1c5d5da918edaa0533a00fa5fd9e19c5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 26 May 2025 01:13:14 +0000 Subject: [PATCH 143/146] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 239 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 162 +- SECURITY.md | 5 - benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 138 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 42 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 4842 +++++++++++++++++ stats_node.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 155 - 54 files changed, 9732 insertions(+), 5041 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 create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts 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/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 8a12ef9..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-05-26T00:56:40.677Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 9b2d21c..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/max-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 d216ea9..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/max-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 19574d1..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: '33 21 * * 3' - - # 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 +``` -```javascript -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -111,12 +117,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
@@ -157,109 +173,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/max_view_buffer_index.h" -``` - -#### stdlib_ndarray_max_view_buffer_index( ndims, \*shape, \*strides, offset ) - -Computes the maximum linear index (in bytes) in an underlying data buffer accessible to an array view. - -```c -#include - -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; - -int64_t idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -// 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. - -```c -int64_t stdlib_ndarray_max_view_buffer_index( const int64_t ndims, const int64_t *shape, const int64_t *strides, const int64_t offset ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include -#include -#include - -int main( void ) { - // Specify the number of dimensions: - const int64_t ndims = 2; - - // Define an array shape: - const int64_t shape[] = { 10, 10 }; - - // Define array strides: - const int64_t strides[] = { -2, 5 }; - - // Define an offset: - const int64_t offset = 100; - - // Compute the maximum accessible index: - int64_t idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - - // Print the results: - printf( "idx: %"PRId64"\n", idx ); -} -``` - -
- - - -
- 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 f40f14b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 04ac010..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/max_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 b0f5a0e..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/max-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..c0ce7dc --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 5c6cc00..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import maxViewBufferIndex from '../docs/types/index'; -export = maxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9934011..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(i,r){return function(){return r||i((r={exports:{}}).exports,r),r.exports}};var f=a(function(m,x){ -function v(i,r,t){var u,n,e;for(u=i.length,n=t,e=0;e0&&(n+=r[e]*(i[e]-1))}return n}x.exports=v -});var c=f();module.exports=c; -/** @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 f54d3d9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 maximum linear index in an underlying data buffer accessible to an array view.\n*\n* @module @stdlib/ndarray-base-max-view-buffer-index\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\n\n// MODULES //\n\nvar maxViewBufferIndex = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAoBC,EAAOC,EAASC,EAAS,CACrD,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAM,OACdI,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAKL,EAAOK,CAAE,IAAM,EACnB,OAAOH,EAEHD,EAASI,CAAE,EAAI,IACnBD,GAAOH,EAASI,CAAE,GAAML,EAAOK,CAAE,EAAI,GAEvC,CACA,OAAOD,CACR,CAKAN,EAAO,QAAUC,ICfjB,IAAIO,EAAqB,IAKzB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "maxViewBufferIndex", "shape", "strides", "offset", "ndims", "idx", "i", "maxViewBufferIndex"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index c200e94..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index 6aed70d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2024 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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 ee081f0..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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/max_view_buffer_index.h" -#include -#include -#include - -int main( void ) { - // Specify the number of dimensions: - const int64_t ndims = 2; - - // Define an array shape: - const int64_t shape[] = { 10, 10 }; - - // Define array strides: - const int64_t strides[] = { -2, 5 }; - - // Define an offset: - const int64_t offset = 100; - - // Compute the maximum accessible index: - int64_t idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - - // Print the results: - printf( "idx: %"PRId64"\n", idx ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index 6a35bfe..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( const int64_t ndims, const int64_t *shape, const int64_t *strides, const int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..dc92a2f --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 34a2595..ace1596 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.2.2", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.4.3", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^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", @@ -89,9 +32,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 c63eb0f..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( const int64_t ndims, const int64_t *shape, const int64_t *strides, const int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..d2dbd79 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..e98040b --- /dev/null +++ b/stats_node.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 ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -}); From b567fb7e4bac1ae99b9959be93c4a07ac40f97c1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Jun 2025 00:55:02 +0000 Subject: [PATCH 144/146] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bbf0038..34a2595 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ }, "dependencies": { "@stdlib/types": "^0.4.3", - "@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-nonnegative-integer": "^0.2.2", @@ -93,4 +94,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From c9555f0f8c4fa44934647b8dc361e74207b7d0d3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Jun 2025 01:11:11 +0000 Subject: [PATCH 145/146] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 4842 -------------------------------------------- stats_node.html | 4842 -------------------------------------------- 6 files changed, 9692 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index c0ce7dc..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 3ff4229..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index dc92a2f..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index 28b42dc..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index d2dbd79..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index e98040b..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 7a9617ff523ccbe8527f4c03710af4fc614e3b43 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Jun 2025 01:11:39 +0000 Subject: [PATCH 146/146] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 239 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 162 +- SECURITY.md | 5 - benchmark/benchmark.js | 61 - benchmark/c/Makefile | 146 - benchmark/c/benchmark.c | 138 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/index.d.ts | 70 - docs/types/test.ts | 76 - examples/c/Makefile | 146 - examples/c/example.c | 42 - examples/index.js | 57 - .../ndarray/base/max_view_buffer_index.h | 40 - index.js | 3 + index.js.map | 1 + lib/index.js | 74 - lib/main.js | 84 - manifest.json | 38 - package.json | 62 +- src/main.c | 57 - stats_browser.html | 4842 +++++++++++++++++ stats_node.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/test.js | 155 - 54 files changed, 9732 insertions(+), 5041 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 create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts 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/max_view_buffer_index.h create mode 100644 index.js create mode 100644 index.js.map 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_browser.html create mode 100644 stats_node.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 95546d0..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-06-30T00:52:47.901Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 9b2d21c..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/max-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 d216ea9..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/max-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 19574d1..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: '33 21 * * 3' - - # 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 +``` -```javascript -var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### maxViewBufferIndex( shape, strides, offset ) @@ -111,12 +117,17 @@ var idx = maxViewBufferIndex( shape, strides, offset ); -```javascript -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 maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); +```html + + + + + + + + + + + ```
@@ -157,109 +173,7 @@ for ( i = 0; i < 100; i++ ) { -* * * - -
- -## C APIs - - - -
- -
- - - - - -
- -### Usage - -```c -#include "stdlib/ndarray/base/max_view_buffer_index.h" -``` - -#### stdlib_ndarray_max_view_buffer_index( ndims, \*shape, \*strides, offset ) - -Computes the maximum linear index (in bytes) in an underlying data buffer accessible to an array view. - -```c -#include - -int64_t ndims = 2; -int64_t shape[] = { 10, 10 }; -int64_t strides[] = { 10, 1 }; -int64_t offset = 0; - -int64_t idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -// 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. - -```c -int64_t stdlib_ndarray_max_view_buffer_index( const int64_t ndims, const int64_t *shape, const int64_t *strides, const int64_t offset ); -``` - -
- - - - - -
- -
- - - - - -
- -### Examples - -```c -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include -#include -#include - -int main( void ) { - // Specify the number of dimensions: - const int64_t ndims = 2; - - // Define an array shape: - const int64_t shape[] = { 10, 10 }; - - // Define array strides: - const int64_t strides[] = { -2, 5 }; - - // Define an offset: - const int64_t offset = 100; - - // Compute the maximum accessible index: - int64_t idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - - // Print the results: - printf( "idx: %"PRId64"\n", idx ); -} -``` - -
- - - -
- 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 f40f14b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var pkg = require( './../package.json' ).name; -var maxViewBufferIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var strides; - var shape; - var out; - var i; - - shape = [ 0, 0, 0 ]; - shape[ 0 ] = discreteUniform( 0, 10 ); - shape[ 1 ] = discreteUniform( 0, 10 ); - shape[ 2 ] = discreteUniform( 0, 10 ); - - strides = shape2strides( shape, 'row-major' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 2 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = maxViewBufferIndex( shape, strides, 1000 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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 04ac010..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/max_view_buffer_index.h" -#include -#include -#include -#include -#include -#include - -#define NAME "max-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; - int64_t n; - double t; - int i; - - 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; - n = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - if ( n > 1e10 ) { - printf( "unexpected result\n" ); - break; - } - } - elapsed = tic() - t; - if ( n > 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 b0f5a0e..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/max-view-buffer-index" -%% click B href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/max-view-buffer-index -[production-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-max-view-buffer-index/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..c0ce7dc --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..3ff4229 --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 5c6cc00..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import maxViewBufferIndex from '../docs/types/index'; -export = maxViewBufferIndex; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9934011..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(i,r){return function(){return r||i((r={exports:{}}).exports,r),r.exports}};var f=a(function(m,x){ -function v(i,r,t){var u,n,e;for(u=i.length,n=t,e=0;e0&&(n+=r[e]*(i[e]-1))}return n}x.exports=v -});var c=f();module.exports=c; -/** @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 f54d3d9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 maximum linear index in an underlying data buffer accessible to an array view.\n*\n* @module @stdlib/ndarray-base-max-view-buffer-index\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );\n*\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\n\n// MODULES //\n\nvar maxViewBufferIndex = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = maxViewBufferIndex;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8DA,SAASC,EAAoBC,EAAOC,EAASC,EAAS,CACrD,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAM,OACdI,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAKL,EAAOK,CAAE,IAAM,EACnB,OAAOH,EAEHD,EAASI,CAAE,EAAI,IACnBD,GAAOH,EAASI,CAAE,GAAML,EAAOK,CAAE,EAAI,GAEvC,CACA,OAAOD,CACR,CAKAN,EAAO,QAAUC,ICfjB,IAAIO,EAAqB,IAKzB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "maxViewBufferIndex", "shape", "strides", "offset", "ndims", "idx", "i", "maxViewBufferIndex"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 3b05267..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( shape, strides, offset ) - Computes the maximum linear index in an underlying data buffer 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: integer - Maximum linear index in an underlying data buffer 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 ) - 59 - > s = [ 30, 10, 1 ]; - > o = 0; - > out = {{alias}}( d, s, o ) - 59 - > s = [ -30, -10, -1 ]; - > o = 59; - > out = {{alias}}( d, s, o ) - 59 - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index c200e94..0000000 --- a/docs/types/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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param shape - array shape -* @param strides - stride array -* @param offset - index offset -* @returns linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -declare function maxViewBufferIndex( shape: ArrayLike, strides: ArrayLike, offset: number ): number; - - -// EXPORTS // - -export = maxViewBufferIndex; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a4120c3..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 maxViewBufferIndex = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - maxViewBufferIndex( [ 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; - maxViewBufferIndex( true, strides, offset ); // $ExpectError - maxViewBufferIndex( false, strides, offset ); // $ExpectError - maxViewBufferIndex( null, strides, offset ); // $ExpectError - maxViewBufferIndex( undefined, strides, offset ); // $ExpectError - maxViewBufferIndex( '5', strides, offset ); // $ExpectError - maxViewBufferIndex( [ '1', '2' ], strides, offset ); // $ExpectError - maxViewBufferIndex( {}, strides, offset ); // $ExpectError - maxViewBufferIndex( ( 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; - maxViewBufferIndex( shape, true, offset ); // $ExpectError - maxViewBufferIndex( shape, false, offset ); // $ExpectError - maxViewBufferIndex( shape, null, offset ); // $ExpectError - maxViewBufferIndex( shape, undefined, offset ); // $ExpectError - maxViewBufferIndex( shape, '5', offset ); // $ExpectError - maxViewBufferIndex( shape, [ '1', '2' ], offset ); // $ExpectError - maxViewBufferIndex( shape, {}, offset ); // $ExpectError - maxViewBufferIndex( 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 ]; - maxViewBufferIndex( shape, strides, true ); // $ExpectError - maxViewBufferIndex( shape, strides, false ); // $ExpectError - maxViewBufferIndex( shape, strides, null ); // $ExpectError - maxViewBufferIndex( shape, strides, undefined ); // $ExpectError - maxViewBufferIndex( shape, strides, '5' ); // $ExpectError - maxViewBufferIndex( shape, strides, [ '1', '2' ] ); // $ExpectError - maxViewBufferIndex( shape, strides, {} ); // $ExpectError - maxViewBufferIndex( shape, strides, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - maxViewBufferIndex(); // $ExpectError - maxViewBufferIndex( [ 10, 10 ] ); // $ExpectError - maxViewBufferIndex( [ 10, 10 ], [ 10, 1 ] ); // $ExpectError -} diff --git a/examples/c/Makefile b/examples/c/Makefile deleted file mode 100644 index 6aed70d..0000000 --- a/examples/c/Makefile +++ /dev/null @@ -1,146 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2024 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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 ee081f0..0000000 --- a/examples/c/example.c +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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/max_view_buffer_index.h" -#include -#include -#include - -int main( void ) { - // Specify the number of dimensions: - const int64_t ndims = 2; - - // Define an array shape: - const int64_t shape[] = { 10, 10 }; - - // Define array strides: - const int64_t strides[] = { -2, 5 }; - - // Define an offset: - const int64_t offset = 100; - - // Compute the maximum accessible index: - int64_t idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); - - // Print the results: - printf( "idx: %"PRId64"\n", idx ); -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6b381c6..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 maxViewBufferIndex = 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 ); - - // Compute the maximum linear index: - idx = maxViewBufferIndex( shape, strides, offset ); - console.log( 'Shape: %s. Strides: %s. Offset: %d. Max idx: %d.', shape.join( 'x' ), strides.join( ',' ), offset, idx ); -} diff --git a/include/stdlib/ndarray/base/max_view_buffer_index.h b/include/stdlib/ndarray/base/max_view_buffer_index.h deleted file mode 100644 index 6a35bfe..0000000 --- a/include/stdlib/ndarray/base/max_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_MAX_VIEW_BUFFER_INDEX_H -#define STDLIB_NDARRAY_BASE_MAX_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 maximum linear index (in bytes) in an underlying data buffer accessible to an array view. -*/ -int64_t stdlib_ndarray_max_view_buffer_index( const int64_t ndims, const int64_t *shape, const int64_t *strides, const int64_t offset ); - -#ifdef __cplusplus -} -#endif - -#endif // !STDLIB_NDARRAY_BASE_MAX_VIEW_BUFFER_INDEX_H diff --git a/index.js b/index.js new file mode 100644 index 0000000..dc92a2f --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,n;e=this,n=function(){"use strict";return function(e,n,f){var t,o,i;for(t=e.length,o=f,i=0;i0&&(o+=n[i]*(e[i]-1))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).maxViewBufferIndex=n(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..28b42dc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../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 maximum linear index in an underlying data buffer 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 {NonNegativeInteger} linear index\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 10, 1 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -10, -1 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ 1, 10 ];\n* var offset = 0;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*\n* @example\n* var shape = [ 10, 10 ];\n* var strides = [ -1, -10 ];\n* var offset = 99;\n*\n* var idx = maxViewBufferIndex( shape, strides, offset );\n* // returns 99\n*/\nfunction maxViewBufferIndex( shape, strides, offset ) {\n\tvar ndims;\n\tvar idx;\n\tvar i;\n\n\tndims = shape.length;\n\tidx = offset;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn offset;\n\t\t}\n\t\tif ( strides[ i ] > 0 ) {\n\t\t\tidx += strides[ i ] * ( shape[ i ] - 1 );\n\t\t}\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default maxViewBufferIndex;\n"],"names":["shape","strides","offset","ndims","idx","i","length"],"mappings":";gDA8DA,SAA6BA,EAAOC,EAASC,GAC5C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAQH,EAAMM,OACdF,EAAMF,EACAG,EAAI,EAAGA,EAAIF,EAAOE,IAAM,CAC7B,GAAoB,IAAfL,EAAOK,GACX,OAAOH,EAEHD,EAASI,GAAM,IACnBD,GAAOH,EAASI,IAAQL,EAAOK,GAAM,GAEtC,CACD,OAAOD,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9cb114e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @module @stdlib/ndarray-base-max-view-buffer-index -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' ); -* -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ - -// MODULES // - -var maxViewBufferIndex = require( './main.js' ); - - -// EXPORTS // - -module.exports = maxViewBufferIndex; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a9f94aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS 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 maximum linear index in an underlying data buffer accessible to an array view. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @returns {NonNegativeInteger} linear index -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 10, 1 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -10, -1 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ 1, 10 ]; -* var offset = 0; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -* -* @example -* var shape = [ 10, 10 ]; -* var strides = [ -1, -10 ]; -* var offset = 99; -* -* var idx = maxViewBufferIndex( shape, strides, offset ); -* // returns 99 -*/ -function maxViewBufferIndex( shape, strides, offset ) { - var ndims; - var idx; - var i; - - ndims = shape.length; - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] === 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} - - -// EXPORTS // - -module.exports = maxViewBufferIndex; 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 34a2595..ace1596 100644 --- a/package.json +++ b/package.json @@ -3,33 +3,7 @@ "version": "0.2.2", "description": "Compute the maximum linear index in an underlying data buffer 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" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -38,37 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.4.3", - "@stdlib/utils-library-manifest": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-nonnegative-integer": "^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", @@ -89,9 +32,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 c63eb0f..0000000 --- a/src/main.c +++ /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. -*/ - -#include "stdlib/ndarray/base/max_view_buffer_index.h" -#include - -/** -* Computes the maximum linear index (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 -* @return maximum linear index -* -* @example -* #include "stdlib/ndarray/base/max_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 idx = stdlib_ndarray_max_view_buffer_index( ndims, shape, strides, offset ); -* // returns 99 -*/ -int64_t stdlib_ndarray_max_view_buffer_index( const int64_t ndims, const int64_t *shape, const int64_t *strides, const int64_t offset ) { - int64_t idx; - int64_t i; - - idx = offset; - for ( i = 0; i < ndims; i++ ) { - if ( shape[ i ] == 0 ) { - return offset; - } - if ( strides[ i ] > 0 ) { - idx += strides[ i ] * ( shape[ i ] - 1 ); - } - } - return idx; -} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..d2dbd79 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..e98040b --- /dev/null +++ b/stats_node.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 ce1833d..0000000 --- a/test/test.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 maxViewBufferIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof maxViewBufferIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, 3 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 5, 'returns expected value' ); - - // 3d array... - shape = [ 2, 3, 10 ]; - - strides = [ 30, 10, 1 ]; - offset = 0; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - strides = [ 30, -10, 1 ]; - offset = 20; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 59, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function computes the maximum linear index in an underlying array buffer which is 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 15, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 15; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 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 = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 10, 'returns expected value' ); - - shape = [ 0, 2 ]; - strides = [ -2, 1 ]; - offset = 14; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 14, 'returns expected value' ); - - shape = [ 0, 0 ]; - strides = [ 2, -1 ]; - offset = 11; - idx = maxViewBufferIndex( shape, strides, offset ); - t.strictEqual( idx, 11, 'returns expected value' ); - - t.end(); -});